当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::request方法代码示例

本文整理汇总了PHP中Context::request方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::request方法的具体用法?PHP Context::request怎么用?PHP Context::request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Context的用法示例。


在下文中一共展示了Context::request方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before

 public function before()
 {
     parent::before();
     $this->_ctx =& Context::instance();
     $this->_ctx->request($this->request)->response($this->response);
     View::bind_global('ctx', $this->_ctx);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:7,代码来源:front.php

示例2: main

 /**
  * Main program
  */
 public static function main()
 {
     $context = new Context();
     $context->request();
     $context->request();
     $context->request();
     $context = null;
 }
开发者ID:luisOO,项目名称:design-patterns,代码行数:11,代码来源:client.php

示例3: __construct

            $c->state = new NormalState();
            echo "<Normal state>\n";
        }
        $c->counter -= 5;
        return $c->counter;
    }
}
class Context
{
    const LIMIT = 10;
    public $state;
    public $counter;
    public function __construct()
    {
        $this->counter = self::LIMIT;
    }
    public function request(int $i) : int
    {
        if ($i == 2) {
            return $this->state->moveUp($this);
        } else {
            return $this->state->moveDown($this);
        }
    }
}
$context = new Context();
$context->state = new NormalState();
for ($i = 0; $i < 500; ++$i) {
    $r = mt_rand(1, 3);
    echo $context->request($r), "\n";
}
开发者ID:edin,项目名称:php-design-patterns,代码行数:31,代码来源:State.php

示例4: handle

    }
}
class StateB implements State
{
    public function handle($context)
    {
        $context->setState(new StateC());
    }
    public function display()
    {
        echo "State B\n";
    }
}
class StateC implements State
{
    public function handle($context)
    {
        $context->setState(new StateA());
    }
    public function display()
    {
        echo "State C\n";
    }
}
//实例化
$objContext = new Context(new StateB());
$objContext->request();
$objContext->request();
$objContext->request();
$objContext->request();
$objContext->request();
开发者ID:rick00young,项目名称:StudyNote,代码行数:31,代码来源:State.php

示例5: handle

    }
    public function handle(Context $context)
    {
        echo 'concrete_b' . "<br>";
        $context->setState(ConcreteStateA::getInstance());
    }
}
class Context
{
    // 环境角色
    private $_state;
    public function __construct()
    {
        // 默认为stateA
        $this->_state = ConcreteStateA::getInstance();
    }
    public function setState(State $state)
    {
        $this->_state = $state;
    }
    public function request()
    {
        $this->_state->handle($this);
    }
}
// client
$context = new Context();
$context->request();
$context->request();
$context->request();
$context->request();
开发者ID:yunkaiyueming,项目名称:php_design_patterns,代码行数:31,代码来源:state.php


注:本文中的Context::request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。