original_string: public function onDispatch(SystemEvent $event)
      {
          $server  = $this->getServer();
          $request = $server->getRequest();
  
          $controllerName = $request->getAttribute('controller');
          if (! $controllerName) {
              throw new RuntimeException(
                  'Unable to dispatch the system event, the server request not '
                  . 'contains the "controller" attribute.'
              );
          }
          $actionName = $request->getAttribute('action', 'index');
  
          $events = $this->getEvents();
  
          $controllers = $this->getControllers();
          $controller  = $controllers->get($controllerName);
          $event->setContext($controller);
  
          $dispatchEvent = new DispatchEvent(
              $controller, $controllerName, $actionName, $event->getParams()
          );
  
          $events->trigger($dispatchEvent);
          $result = $dispatchEvent->getResult();
          $target = SystemEvent::DISPATCH;
          if ($result instanceof ResponseInterface) {
              $target = SystemEvent::FINISH;
          }
          $event->setResult($target, $result);
      }
code: public function onDispatch(SystemEvent $event)
      {
          $server  = $this->getServer();
          $request = $server->getRequest();
  
          $controllerName = $request->getAttribute('controller');
          if (! $controllerName) {
              throw new RuntimeException(
                  'Unable to dispatch the system event, the server request not '
                  . 'contains the "controller" attribute.'
              );
          }
          $actionName = $request->getAttribute('action', 'index');
  
          $events = $this->getEvents();
  
          $controllers = $this->getControllers();
          $controller  = $controllers->get($controllerName);
          $event->setContext($controller);
  
          $dispatchEvent = new DispatchEvent(
              $controller, $controllerName, $actionName, $event->getParams()
          );
  
          $events->trigger($dispatchEvent);
          $result = $dispatchEvent->getResult();
          $target = SystemEvent::DISPATCH;
          if ($result instanceof ResponseInterface) {
              $target = SystemEvent::FINISH;
          }
          $event->setResult($target, $result);
      }
code_tokens: public function onDispatch ( SystemEvent $ event ) { $ server = $ this -> getServer ( ) ; $ request = $ server -> getRequest ( ) ; $ controllerName = $ request -> getAttribute ( 'controller' ) ; if ( ! $ controllerName ) { throw new RuntimeException ( 'Unable to dispatch the system event, the server request not ' . 'contains the "controller" attribute.' ) ; } $ actionName = $ request -> getAttribute ( 'action' , 'index' ) ; $ events = $ this -> getEvents ( ) ; $ controllers = $ this -> getControllers ( ) ; $ controller = $ controllers -> get ( $ controllerName ) ; $ event -> setContext ( $ controller ) ; $ dispatchEvent = new DispatchEvent ( $ controller , $ controllerName , $ actionName , $ event -> getParams ( ) ) ; $ events -> trigger ( $ dispatchEvent ) ; $ result = $ dispatchEvent -> getResult ( ) ; $ target = SystemEvent :: DISPATCH ; if ( $ result instanceof ResponseInterface ) { $ target = SystemEvent :: FINISH ; } $ event -> setResult ( $ target , $ result ) ; }
docstring: Triggers the DispatchEvent.
  
  @param \Es\System\SystemEvent $event The system event
  
  @throws \RuntimeException If the ServerRequest not contain the
  "controller" attribute
docstring_tokens: Triggers the DispatchEvent .