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


PHP HttpKernel::getRequest方法代码示例

本文整理汇总了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());
 }
开发者ID:KinaMarie,项目名称:SimpleCASBundle,代码行数:11,代码来源:SimpleCAS.php

示例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');
 }
开发者ID:notbrain,项目名称:symfony,代码行数:20,代码来源:HttpKernelTest.php


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