Esempio n. 1
0
 public function onRequest(GetResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $request = $event->getRequest();
     $modifiers = $this->getModifiers();
     $matches = array();
     foreach ($modifiers as $modifier) {
         $provider = $modifier->getProvider();
         $modifierKey = $modifier->getModifierKey();
         $method = $modifier->getMethod();
         if ($method->contains($request, $modifierKey)) {
             $matches[$provider->getProviderId()] = array('method' => $method, 'modifier' => $modifierKey, 'provider_key' => $provider->getProviderId(), 'provider' => $modifier->getProvider(), 'value' => $modifier->getValue());
         }
     }
     foreach ($matches as $match) {
         if (!$match['method'] instanceof RequestAlteringInterface) {
             continue;
         }
         $match['method']->alterRequest($request, $match['modifier']);
         $this->reinitializeRequest($request);
     }
     foreach ($matches as $match) {
         $event = new ModifierMatchedEvent($request, $match['provider_key'], $match['method'], $match['modifier'], $match['value']);
         $dispatcher->dispatch(PurlEvents::MODIFIER_MATCHED, $event);
         $this->matchedModifiers->add($event);
     }
     $request->attributes->set('purl.matched_modifiers', $matches);
 }