Last active
December 24, 2015 09:09
-
-
Save JJK801/6775056 to your computer and use it in GitHub Desktop.
Code illustration for M6Web article
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
<?php | |
namespace M6\Bundle\MyBundle\Listener; | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | |
use Symfony\Component\HttpKernel\KernelEvents; | |
use M6\Bundle\MyBundle\Helper\MyHelper; | |
class MyEventSubscriber implements EventSubscriberInterface | |
{ | |
protected $helper = null; | |
public function __construct(MyHelper $myHelper) | |
{ | |
$this->helper = $myHelper; | |
} | |
static public function getSubscribedEvents() | |
{ | |
$subscriber = array( | |
KernelEvents::REQUEST => array( | |
array('onKernelRequest', 0), | |
) | |
); | |
return $subscriber; | |
} | |
public function onKernelRequest(GetResponseEvent $event) | |
{ | |
$this->helper->doSomething($event->getRequest()->getPathInfo()); | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment