示例#1
0
 /**
  * Set the ip by listening on core.request.
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (null === $this->requestStack) {
         return;
     }
     $request = $this->requestStack->getCurrentRequest();
     if (null === $request) {
         return;
     }
     $ip = $request->getClientIp();
     if (null !== $ip) {
         $this->ipTraceableListener->setIpValue($ip);
     }
 }
 private function getCurrentRequest()
 {
     if (null !== $this->requestStack) {
         if ($this->requestStack instanceof Request) {
             return $this->requestStack;
         } else {
             return $this->requestStack->getCurrentRequest();
         }
     }
     return $this->container->get('request');
 }
示例#3
0
 /**
  * Returns the current Request.
  *
  * @return Request
  */
 protected function getRequest()
 {
     return $this->requestStack->getCurrentRequest();
 }
 /**
  * @param RequestStack|Request $requestStack
  */
 public function setRequest($requestStack)
 {
     if ($requestStack instanceof Request) {
         $this->request = $requestStack;
     } elseif ($requestStack instanceof RequestStack) {
         $this->request = $requestStack->getCurrentRequest();
     } else {
         throw new \InvalidArgumentException('Argument 1 should be an instance of Symfony\\Component\\HttpFoundation\\RequestStack or Symfony\\Component\\HttpFoundation\\Request');
     }
 }
 /**
  * @param RequestStack|Request $requestStack
  */
 public function setRequest($requestStack)
 {
     if ($requestStack instanceof Request) {
         $this->request = $requestStack;
     } elseif ($requestStack instanceof RequestStack) {
         $this->request = $requestStack->getCurrentRequest();
     }
 }