本文整理汇总了PHP中Symfony\Component\HttpKernel\Event\FilterResponseEvent::stopPropagation方法的典型用法代码示例。如果您正苦于以下问题:PHP FilterResponseEvent::stopPropagation方法的具体用法?PHP FilterResponseEvent::stopPropagation怎么用?PHP FilterResponseEvent::stopPropagation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Event\FilterResponseEvent
的用法示例。
在下文中一共展示了FilterResponseEvent::stopPropagation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onKernelResponse
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();
}
}
示例2: onResponse
/**
* 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());
}
示例3: onKernelResponse
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();
}
}
示例4: configureCache
/**
* 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();
}