本文整理汇总了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');
}