本文整理汇总了PHP中Bluz\Proxy\Request::setInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::setInstance方法的具体用法?PHP Request::setInstance怎么用?PHP Request::setInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bluz\Proxy\Request
的用法示例。
在下文中一共展示了Request::setInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initRequest
/**
* get CLI Request
*
* @return Cli\Request
*/
public function initRequest()
{
$request = new Cli\Request();
if ($config = Config::getData('request')) {
$request->setOptions($config);
}
Request::setInstance($request);
}
示例2: testProcessRequest
/**
* Process Request
*/
public function testProcessRequest()
{
$request = Request::getInstance();
$request = $request->withQueryParams(['arr-page' => 2, 'arr-limit' => 2, 'arr-order-id' => 'desc', 'arr-filter-name' => 'ne-Smith', 'arr-filter-status' => 'disable']);
Request::setInstance($request);
$grid = new ArrayGrid();
$this->assertEquals(8, $grid->total());
$this->assertEquals(4, $grid->pages());
}
示例3: initRequest
/**
* get CLI Request
* @return void
* @throws ApplicationException
*/
public function initRequest()
{
$arguments = getopt("u:", ["uri:"]);
if (!array_key_exists('u', $arguments) && !array_key_exists('uri', $arguments)) {
throw new ApplicationException('Attribute `--uri` is required');
}
$uri = $arguments['u'] ?? $arguments['uri'];
$request = RequestFactory::fromGlobals(['REQUEST_URI' => $uri, 'REQUEST_METHOD' => 'CLI']);
Request::setInstance($request);
}
示例4: testErrorController
/**
* Test run Error Controller
*/
public function testErrorController()
{
// setup Request
$request = new ServerRequest([], [], uniqid('module') . '/' . uniqid('controller'), Request::METHOD_GET);
Request::setInstance($request);
// run Application
$this->getApp()->process();
$this->assertEquals(Router::getErrorModule(), $this->getApp()->getModule());
$this->assertEquals(Router::getErrorController(), $this->getApp()->getController());
}
示例5: resetApp
/**
* Reset layout and Request
*/
protected static function resetApp()
{
if (self::$app) {
self::$app->useLayout(true);
}
Proxy\Auth::clearIdentity();
Proxy\Messages::popAll();
Proxy\Request::setInstance(new Http\Request());
Proxy\Response::setInstance(new Http\Response());
Proxy\Response::setPresentation(null);
}
示例6: initRequest
/**
* Initial Request instance
* @return void
*/
protected function initRequest()
{
$request = new Http\Request();
$request->setOptions(Config::getData('request'));
Request::setInstance($request);
}
示例7: resetApp
/**
* Reset layout and Request
*/
protected static function resetApp()
{
if (self::$app) {
self::$app->useLayout(true);
self::$app->resetRouter();
}
Proxy\Auth::clearIdentity();
Proxy\Messages::popAll();
Proxy\Request::setInstance(RequestFactory::fromGlobals());
Proxy\Response::setInstance(new Bluz\Response\Response());
}
示例8: initRequest
/**
* Initial Request instance
*
* @return void
*/
protected function initRequest()
{
$request = RequestFactory::fromGlobals();
Request::setInstance($request);
}
示例9: resetRequest
/**
* Reset Request
*
* @return void
*/
protected function resetRequest()
{
$request = Request::getInstance();
// priority:
// - default values
// - from GET query
// - from path
$request = $request->withQueryParams(array_merge(['_module' => $this->getDefaultModule(), '_controller' => $this->getDefaultController()], $request->getQueryParams(), $this->params));
Request::setInstance($request);
}