getRequestType() public method

Returns the request type the kernel is currently processing
public getRequestType ( ) : integer
return integer One of HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST
 /**
  * Method called on kernel.request event. Handle only "subrequest"
  * @param KernelEvent $event The received event
  *
  * @return void
  */
 public function onKernelRequest(KernelEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST == $event->getRequestType() || null === $this->cacheService) {
         return;
     }
     $request = $event->getRequest();
     if ($request->attributes->has('server_cache')) {
         $cacheKey = $this->getRequestCacheKey($request);
         $request->attributes->set('cache_key', $cacheKey);
         $controller = $request->attributes->get('controllerName');
         $fromCache = false;
         $responseContent = $this->cacheService->get($cacheKey);
         if ($responseContent || $responseContent === '' && !$request->attributes->get('ignore_errors')) {
             $response = new Response($responseContent);
             $response->headers->set('server_cached', 1);
             $event->setResponse($response);
             if ($this->debug) {
                 $this->decorateResponse($request, $response, $controller, true);
             }
             $fromCache = true;
         }
         $this->cachedBlocks[$controller . ' - key : ' . $cacheKey] = $fromCache;
     }
 }
 /**
  * Check event status.
  *
  *   - HttpKernelInterface::MASTER_REQUEST === 1
  *   - HttpKernelInterface::SUB_REQUEST === 2
  *
  * @param KernelEvent $event The KernelEvent
  *
  * @return void
  *
  * @api
  */
 public function onCoreController(KernelEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
         $this->controller = $event->getController();
         if (isset($this->controller[0])) {
             $this->controller = $this->controller[0];
             if (method_exists($this->controller, 'preExecute')) {
                 $this->controller->preExecute();
             }
         }
     }
 }
Esempio n. 3
0
 /**
  * Handles onKernelRequest events.
  */
 public function onKernelRequest(KernelEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
         $this->beforeDispatched = true;
         $this['dispatcher']->dispatch(SilexEvents::BEFORE, $event);
     }
 }
 /**
  * @param KernelEvent $event
  * @return bool
  */
 protected function eventRequestMatches(KernelEvent $event)
 {
     return $this->requestMatcher->matches($event->getRequest(), $event->getRequestType());
 }
Esempio n. 5
0
 /**
  * @inheritdoc
  */
 public function onKernelRequest(KernelEvent $event)
 {
     if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
         $this->channel = $this->channelResolver->resolve($event->getRequest()->getHost());
     }
 }
 /**
  * @param KernelEvent $event
  */
 public function onRequest(KernelEvent $event)
 {
     if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
         $this->uriProvider->setRequest($event->getRequest());
     }
 }
 /**
  * @param KernelEvent $event
  *
  * @return bool
  */
 private function isMasterRequest(KernelEvent $event)
 {
     return HttpKernelInterface::MASTER_REQUEST === $event->getRequestType();
 }