Created
May 10, 2017 08:33
-
-
Save poznet/842ae820a230ba982a66f854549b0e2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Poznet\FrontendBundle\EventListener; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; | |
use Symfony\Component\HttpFoundation\RedirectResponse; | |
class LiipListener | |
{ | |
private $resolver; | |
public function __construct(\Liip\ImagineBundle\Imagine\Cache\CacheManager $r){ | |
$this->resolver=$r; | |
} | |
public function onRequest(GetResponseEvent $event){ | |
if (!$event->isMasterRequest()) { | |
$req=$event->getRequest(); | |
$url=$req->getRequestUri(); | |
$tab=explode('/',$url); | |
if(count($tab)>5) { | |
if (($tab[count($tab) - 5] == 'cache') && ($tab[count($tab) - 3] == 'fotki')) { | |
$tab[count($tab) - 5]='cache/resolve'; | |
$gotowe=implode('/',$tab); | |
echo $gotowe; | |
$event->getRequest()->server->set('REQUEST_URI', $gotowe); | |
$event->getRequest()->initialize($event->getRequest()->query->all(), $event->getRequest()->request->all(), $event->getRequest()->attributes->all(), $event->getRequest()->cookies->all(), $event->getRequest()->files->all(), $event->getRequest()->server->all(), $event->getRequest()->getContent()); | |
$response = new RedirectResponse($gotowe); | |
$event->setResponse($response); | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kernel.listener.liiplistener: | |
class: Poznet\FrontendBundle\EventListener\LiipListener | |
arguments : [ @liip_imagine.cache.manager ] | |
tags: | |
- { name: kernel.event_listener, event: kernel.request, method: onRequest } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment