public function onKernelResponse(FilterResponseEvent $event) { if (null != $this->ciudad) { if ($this->contexto->isGranted('ROLE_TIENDA')) { $portada = $this->router->generate('extranet_portada'); } else { $portada = $this->router->generate('portada', array('ciudad' => $this->ciudad)); } $event->setResponse(new RedirectResponse($portada)); $event->stopPropagation(); } }
/** * This method is executed on kernel.response event * * @param FilterResponseEvent $event * * @see {http://symfony.com/doc/current/components/http_kernel/introduction.html#the-kernel-response-event} */ public function onResponse(FilterResponseEvent $event) { $request = $event->getRequest(); if ($request->attributes->get('response_source') === 'cache') { //Prevents re-caching response from cache $event->stopPropagation(); return; } if (!$event->isMasterRequest()) { return; //Caching should only occur on master requests, see https://github.com/kiler129/SupercacheBundle/issues/10 } $this->responseHandler->cacheResponse($event->getRequest(), $event->getResponse()); }
public function onKernelResponse(FilterResponseEvent $event) { if ($this->user != null) { if ($this->contexto->isGranted('ROLE_USER')) { $portada = $this->router->generate('user_index', array('id' => 'default')); } else { if ($this->contexto->isGranted('ROLE_ADMIN')) { $portada = $this->router->generate('admin_index'); } else { if ($this->contexto->isGranted('ROLE_SUPER')) { $portada = $this->router->generate('super_index'); } else { $portada = $this->router->generate('static_index'); } } } $event->setResponse(new RedirectResponse($portada)); $event->stopPropagation(); } }
/** * Configures the caching headers on tag view. * * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event */ public function configureCache(FilterResponseEvent $event) { $view = $event->getRequest()->attributes->get('view'); if (!$view instanceof CachableView || !$view instanceof TagView) { return; } if (!$this->enableViewCache || !$view->isCacheEnabled()) { return; } $tag = $view->getTag(); $response = $event->getResponse(); $response->setPublic(); $response->headers->set('X-Tag-Id', $tag->id, false); if ($this->enableTtlCache && !$response->headers->hasCacheControlDirective('s-maxage')) { $response->setSharedMaxAge($this->defaultTtl); } if (!$response->headers->has('Last-Modified')) { $response->setLastModified($tag->modificationDate); } // We stop the propagation here so default cache view listener wouldn't mess with our view object. // All listeners that modify the cache for tag view object should run before this event $event->stopPropagation(); }