本文整理匯總了PHP中Symfony\Component\HttpKernel\HttpKernel::getRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP HttpKernel::getRequest方法的具體用法?PHP HttpKernel::getRequest怎麽用?PHP HttpKernel::getRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\HttpKernel\HttpKernel
的用法示例。
在下文中一共展示了HttpKernel::getRequest方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getCurrentUrl
/**
* Returns the current URL without CAS-affecting parameters.
*
* @return string
*/
public function getCurrentUrl()
{
$replacements = array('/\\?logout/' => '', '/&ticket=[^&]*/' => '', '/\\?ticket=[^&;]*/' => '?', '/\\?%26/' => '?', '/\\?&/' => '?', '/\\?$/' => '');
$request = $this->kernel->getRequest();
return preg_replace(array_keys($replacements), array_values($replacements), $request->getUri());
}
示例2: testHandleRestoresThePreviousRequestOnException
public function testHandleRestoresThePreviousRequestOnException()
{
$dispatcher = new EventDispatcher();
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$kernel = new HttpKernel($dispatcher, $resolver);
$request = new Request();
$expected = new \Exception();
$controller = function () use($expected) {
throw $expected;
};
$resolver->expects($this->once())->method('getController')->with($request)->will($this->returnValue($controller));
$resolver->expects($this->once())->method('getArguments')->with($request, $controller)->will($this->returnValue(array()));
try {
$kernel->handle($request);
$this->fail('->handle() suppresses the controller exception');
} catch (\Exception $actual) {
$this->assertSame($expected, $actual, '->handle() throws the controller exception');
}
$this->assertNull($kernel->getRequest(), '->handle() restores the parent (null) request when the controller throws an exception');
}