當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。