diff --git a/EventListener/RatingUpdateInfoEventListener.php b/EventListener/RatingUpdateInfoEventListener.php index 978a4c6..4643899 100644 --- a/EventListener/RatingUpdateInfoEventListener.php +++ b/EventListener/RatingUpdateInfoEventListener.php @@ -11,15 +11,18 @@ class RatingUpdateInfoEventListener implements EventSubscriberInterface { /** - * @var \Symfony\Component\HttpFoundation\Request + * @var Request */ private $request; - public function __construct(Container $container) + /** + * Set request + * + * @param Request $request + */ + public function setRequest(Request $request = null) { - $container->enterScope('request'); - $container->set('request', new Request(), 'request'); - $this->request = $container->get('request'); + $this->request = $request; } public static function getSubscribedEvents() @@ -31,6 +34,10 @@ public static function getSubscribedEvents() public function updatePermalink(RatingEvent $event) { + if (null === $this->request) { + return; + } + $rating = $event->getRating(); if (null === $rating->getPermalink()) { diff --git a/Resources/config/event.xml b/Resources/config/event.xml index 2de1f2d..debd10e 100644 --- a/Resources/config/event.xml +++ b/Resources/config/event.xml @@ -15,7 +15,9 @@ - + + +