當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HttpFoundation\Request類代碼示例

本文整理匯總了PHP中Thelia\Core\HttpFoundation\Request的典型用法代碼示例。如果您正苦於以下問題:PHP Request類的具體用法?PHP Request怎麽用?PHP Request使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Request類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 protected function setUp()
 {
     $this->controller = $controller = $this->getMock("Thelia\\Controller\\BaseController", ["getParser", "render", "renderRaw"]);
     /**
      * Reset static :: $formDefinition on controllers
      */
     $this->definitionReflection = $reflection = (new \ReflectionObject($this->controller))->getProperty('formDefinition');
     $reflection->setAccessible(true);
     $this->formDefinition = $reflection->getValue();
     $reflection->setValue(null);
     /**
      * Add the test type to the factory and
      * the form to the container
      */
     $factory = new FormFactoryBuilder();
     $factory->addExtension(new CoreExtension());
     $factory->addType(new TestType());
     /**
      * Construct the container
      */
     $container = new Container();
     $container->set("thelia.form_factory_builder", $factory);
     $container->set("thelia.translator", new Translator($container));
     $container->setParameter("thelia.parser.forms", array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
     $request = new Request();
     $request->setSession(new Session(new MockArraySessionStorage()));
     $container->set("request", $request);
     $container->set("thelia.forms.validator_builder", new ValidatorBuilder());
     $container->set("event_dispatcher", new EventDispatcher());
     $this->controller->setContainer($container);
 }
開發者ID:badelas,項目名稱:thelia,代碼行數:31,代碼來源:BaseControllerTest.php

示例2: __construct

 public function __construct(Request $request)
 {
     if ($request->getSession() != null) {
         $this->locale = $request->getSession()->getLang()->getLocale();
     } else {
         $this->locale = Lang::getDefaultLanguage()->getLocale();
     }
 }
開發者ID:alex63530,項目名稱:thelia,代碼行數:8,代碼來源:TinyMCELanguage.php

示例3: getGetResponseEvent

 protected function getGetResponseEvent()
 {
     $request = new Request();
     $request->setSession(new Session(new MockArraySessionStorage()));
     /** @var HttpKernelInterface $kernelMock */
     $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->getMock();
     return new GetResponseEvent($kernelMock, $request, HttpKernelInterface::MASTER_REQUEST);
 }
開發者ID:vigourouxjulien,項目名稱:thelia,代碼行數:8,代碼來源:RequestListenerTest.php

示例4: init

 protected function init()
 {
     $container = $this->getContainer();
     $request = new Request();
     $request->setSession(new Session(new MockArraySessionStorage()));
     /** @var RequestStack $requestStack */
     $requestStack = $container->get('request_stack');
     $requestStack->push($request);
 }
開發者ID:vigourouxjulien,項目名稱:thelia,代碼行數:9,代碼來源:AdminUpdatePasswordCommand.php

示例5: setUp

 public function setUp()
 {
     $session = new Session(new MockArraySessionStorage());
     $request = new Request();
     $request->setSession($session);
     $this->mailerFactory = $this->getMockBuilder("Thelia\\Mailer\\MailerFactory")->disableOriginalConstructor()->getMock();
     $translator = new Translator(new Container());
     $this->tokenProvider = new TokenProvider($request, $translator, 'test');
 }
開發者ID:GuiminZHOU,項目名稱:thelia,代碼行數:9,代碼來源:AdministratorTest.php

示例6: getContainer

 public function getContainer()
 {
     $container = new ContainerBuilder();
     $container->set("event_dispatcher", $this->getDispatcher());
     $request = new Request();
     $request->setSession($this->session);
     $container->set("request", $request);
     return $container;
 }
開發者ID:vigourouxjulien,項目名稱:thelia,代碼行數:9,代碼來源:ImageTest.php

示例7: getContainer

 public function getContainer()
 {
     $container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
     $container->set("event_dispatcher", $this->getDispatcher());
     $request = new Request();
     $request->setSession($this->session);
     $container->set("request", $request);
     return $container;
 }
開發者ID:alex63530,項目名稱:thelia,代碼行數:9,代碼來源:ImageTest.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     $session = new Session(new MockArraySessionStorage());
     $request = new Request();
     $request->setSession($session);
     $this->requestStack = new RequestStack();
     $this->requestStack->push($request);
 }
開發者ID:vigourouxjulien,項目名稱:thelia,代碼行數:9,代碼來源:LangTest.php

示例9: append

 /**
  * A simple helper to insert an entry in the admin log
  *
  * @param $resource
  * @param $action
  * @param $message
  * @param Request       $request
  * @param UserInterface $adminUser
  * @param bool          $withRequestContent
  */
 public static function append($resource, $action, $message, Request $request, UserInterface $adminUser = null, $withRequestContent = true)
 {
     $log = new AdminLog();
     $log->setAdminLogin($adminUser !== null ? $adminUser->getUsername() : '<no login>')->setAdminFirstname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getFirstname() : '<no first name>')->setAdminLastname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getLastname() : '<no last name>')->setResource($resource)->setAction($action)->setMessage($message)->setRequest($request->toString($withRequestContent));
     try {
         $log->save();
     } catch (\Exception $ex) {
         Tlog::getInstance()->err("Failed to insert new entry in AdminLog: {ex}", array('ex' => $ex));
     }
 }
開發者ID:badelas,項目名稱:thelia,代碼行數:20,代碼來源:AdminLog.php

示例10: getContainer

 public function getContainer()
 {
     $container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
     $dispatcher = $this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface");
     $container->set("event_dispatcher", $dispatcher);
     $fileManager = new FileManager(["document.product" => "Thelia\\Model\\ProductDocument", "image.product" => "Thelia\\Model\\ProductImage", "document.category" => "Thelia\\Model\\CategoryDocument", "image.category" => "Thelia\\Model\\CategoryImage", "document.content" => "Thelia\\Model\\ContentDocument", "image.content" => "Thelia\\Model\\ContentImage", "document.folder" => "Thelia\\Model\\FolderDocument", "image.folder" => "Thelia\\Model\\FolderImage", "document.brand" => "Thelia\\Model\\BrandDocument", "image.brand" => "Thelia\\Model\\BrandImage"]);
     $container->set("thelia.file_manager", $this->getFileManager());
     $request = new Request();
     $request->setSession($this->session);
     $container->set("request", $request);
     return $container;
 }
開發者ID:margery,項目名稱:thelia,代碼行數:12,代碼來源:DocumentTest.php

示例11: getContainer

 public function getContainer()
 {
     $container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
     $container->set("thelia.translator", new Translator(new Container()));
     $dispatcher = $this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface");
     $container->set("event_dispatcher", $dispatcher);
     $request = new Request();
     $request->setSession($this->getSession());
     $container->set("request", $request);
     $container->set("thelia.securitycontext", new SecurityContext($request));
     $this->buildContainer($container);
     return $container;
 }
開發者ID:alex63530,項目名稱:thelia,代碼行數:13,代碼來源:ContainerAwareTestCase.php

示例12: notifyAction

 /**
  * @param Request $request
  * @param $orderId
  * @return Response
  * @throws \Exception
  */
 public function notifyAction(Request $request, $orderId)
 {
     $token = $request->get('token');
     /** @var PaylineManager $payline */
     $payline = $this->getContainer()->get('payline.manager');
     if ($payline->getWebPaymentDetails($token)) {
         $this->confirmPayment($orderId);
         $this->cleanExpiredLog();
         return new Response();
     }
     $this->cancelPayment($orderId);
     $this->cleanExpiredLog();
     return new Response();
 }
開發者ID:Alban-io,項目名稱:Payline,代碼行數:20,代碼來源:PaymentController.php

示例13: 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

示例14: 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

示例15: checkApiAccess

 private function checkApiAccess(Request $request)
 {
     $key = $request->headers->get('authorization');
     if (null !== $key) {
         $key = substr($key, 6);
     }
     $apiAccount = ApiQuery::create()->findOneByApiKey($key);
     if (null === $apiAccount) {
         throw new UnauthorizedHttpException('Token');
     }
     $secureKey = pack('H*', $apiAccount->getSecureKey());
     $sign = hash_hmac('sha1', $request->getContent(), $secureKey);
     if ($sign != $request->query->get('sign')) {
         throw new PreconditionFailedHttpException('wrong body request signature');
     }
     return $apiAccount;
 }
開發者ID:NandoKstroNet,項目名稱:thelia,代碼行數:17,代碼來源:ControllerListener.php


注:本文中的Thelia\Core\HttpFoundation\Request類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。