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


PHP Request::create方法代码示例

本文整理汇总了PHP中Thelia\Core\HttpFoundation\Request::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::create方法的具体用法?PHP Request::create怎么用?PHP Request::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thelia\Core\HttpFoundation\Request的用法示例。


在下文中一共展示了Request::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createSubRequest

 /**
  * @param string $uri
  * @param Request $request
  * @return Request
  */
 protected function createSubRequest($uri, Request $request)
 {
     $cookies = $request->cookies->all();
     $server = $request->server->all();
     // Override the arguments to emulate a sub-request.
     // Sub-request object will point to localhost as client ip and real client ip
     // will be included into trusted header for client ip
     try {
         if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
             $currentXForwardedFor = $request->headers->get($trustedHeaderName, '');
             $server['HTTP_' . $trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor . ', ' : '') . $request->getClientIp();
         }
     } catch (\InvalidArgumentException $e) {
         // Do nothing
     }
     $server['REMOTE_ADDR'] = '127.0.0.1';
     $subRequest = TheliaRequest::create($uri, 'get', array(), $cookies, array(), $server);
     if ($request->headers->has('Surrogate-Capability')) {
         $subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability'));
     }
     if ($session = $request->getSession()) {
         $subRequest->setSession($session);
     }
     return $subRequest;
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:30,代码来源:InlineFragmentRenderer.php

示例2: handle

 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if (!$request instanceof \Thelia\Core\HttpFoundation\Request) {
         $request = TheliaRequest::create($request->getUri(), $request->getMethod(), $request->getMethod() == 'GET' ? $request->query->all() : $request->request->all(), $request->cookies->all(), $request->files->all(), $request->server->all(), $request->getContent());
     }
     return parent::handle($request, $type, $catch);
 }
开发者ID:margery,项目名称:thelia,代码行数:7,代码来源:HttpCache.php

示例3: initRequest

 /**
  * For init an Request, if your command has need an Request
  * @param Lang|null $lang
  * @since 2.3
  */
 protected function initRequest(Lang $lang = null)
 {
     $container = $this->getContainer();
     $request = Request::create($this->getBaseUrl($lang));
     $request->setSession(new Session(new MockArraySessionStorage()));
     $container->set("request_stack", new RequestStack());
     $container->get('request_stack')->push($request);
     $requestContext = new RequestContext();
     $requestContext->fromRequest($request);
     $url = $container->get('thelia.url.manager');
     $url->setRequestContext($requestContext);
 }
开发者ID:thelia,项目名称:thelia,代码行数:17,代码来源:ContainerAwareCommand.php

示例4: testMatchRequestWithDifferentLocaleAndDomain

 /**
  * covers RewritingRouter::matchRequest
  */
 public function testMatchRequestWithDifferentLocaleAndDomain()
 {
     ConfigQuery::write('rewriting_enable', 1);
     ConfigQuery::write('one_domain_foreach_lang', 1);
     $defaultLang = LangQuery::create()->findOneByLocale('en_US');
     $defaultLang->setUrl('http://test_en.com');
     $frenchLang = LangQuery::create()->findOneByLocale('fr_FR');
     $saveUrl = $frenchLang->getUrl();
     $frenchLang->setUrl('http://test.com')->save();
     $product = ProductQuery::create()->findOne();
     $product->setLocale($defaultLang->getLocale());
     $rewriting = RewritingUrlQuery::create()->filterByView('product')->filterByViewId($product->getId())->filterByViewLocale('fr_FR')->filterByRedirected(null)->findOne();
     $request = Request::create('http://test_en.com/' . $rewriting->getUrl());
     $session = new Session(new MockArraySessionStorage());
     $session->setLang($defaultLang);
     $request->setSession($session);
     $url = new URL();
     $requestContext = new RequestContext();
     $requestContext->fromRequest($request);
     $url->setRequestContext($requestContext);
     try {
         $rewritingRouter = new RewritingRouter();
         $parameters = $rewritingRouter->matchRequest($request);
     } catch (RedirectException $e) {
         $this->assertRegExp("/http:\\/\\/test\\.com\\/.*/", $e->getUrl());
         return;
     }
     $this->fail('->matchRequest must throw a RedirectException');
 }
开发者ID:NandoKstroNet,项目名称:thelia,代码行数:32,代码来源:RewritingRouterTest.php

示例5: filterRequest

 /**
  * Converts the BrowserKit request to a HttpKernel request.
  *
  * @param DomRequest $request A Request instance
  *
  * @return Request A Request instance
  */
 protected function filterRequest(DomRequest $request)
 {
     $httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent());
     $httpRequest->files->replace($this->filterFiles($httpRequest->files->all()));
     return $httpRequest;
 }
开发者ID:alex63530,项目名称:thelia,代码行数:13,代码来源:Client.php


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