Ejemplo n.º 1
0
 /**
  * Handles security.
  *
  * @param EventInterface $event An EventInterface instance
  */
 public function handle(EventInterface $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) {
         return;
     }
     $request = $event->get('request');
     // disconnect all listeners from core.security to avoid the overhead
     // of most listeners having to do this manually
     $this->dispatcher->disconnect('core.security');
     // ensure that listeners disconnect from wherever they have connected to
     foreach ($this->currentListeners as $listener) {
         $listener->unregister($this->dispatcher);
     }
     // register listeners for this firewall
     list($listeners, $exception) = $this->map->getListeners($request);
     if (null !== $exception) {
         $exception->register($this->dispatcher);
     }
     foreach ($listeners as $listener) {
         $listener->register($this->dispatcher);
     }
     // save current listener instances
     $this->currentListeners = $listeners;
     if (null !== $exception) {
         $this->currentListeners[] = $exception;
     }
     // initiate the listener chain
     $ret = $this->dispatcher->notifyUntil($securityEvent = new Event($request, 'core.security', array('request' => $request)));
     if ($securityEvent->isProcessed()) {
         $event->setProcessed();
         return $ret;
     }
 }