original_string: public function dispatch($controller, $action = null, array $params = array(), $throwException = true)
      {
          $notFound = array();
          $action || $action = $this->defaultAction;
          $classes = $this->getControllerClasses($controller);
  
          foreach ($classes as $class) {
              if (!class_exists($class)) {
                  $notFound['controllers'][$controller][] = $class;
                  continue;
              }
              if (!$this->isActionAvailable($class, $action)) {
                  $notFound['actions'][$action][$controller][] = $class;
                  continue;
              }
  
              // Find out existing controller and action
              $this->setController($controller);
              $this->setAction($action);
              $this->request->set($params);
              try {
                  $instance = $this->getControllerInstance($class);
  
                  return $this->execute($instance, $action);
              } catch (\RuntimeException $e) {
                  if ($e->getCode() === self::FORWARD) {
                      return $this->response;
                  } else {
                      throw $e;
                  }
              }
          }
  
          if ($throwException) {
              throw $this->buildException($notFound);
          } else {
              return $notFound;
          }
      }
code: public function dispatch($controller, $action = null, array $params = array(), $throwException = true)
      {
          $notFound = array();
          $action || $action = $this->defaultAction;
          $classes = $this->getControllerClasses($controller);
  
          foreach ($classes as $class) {
              if (!class_exists($class)) {
                  $notFound['controllers'][$controller][] = $class;
                  continue;
              }
              if (!$this->isActionAvailable($class, $action)) {
                  $notFound['actions'][$action][$controller][] = $class;
                  continue;
              }
  
              // Find out existing controller and action
              $this->setController($controller);
              $this->setAction($action);
              $this->request->set($params);
              try {
                  $instance = $this->getControllerInstance($class);
  
                  return $this->execute($instance, $action);
              } catch (\RuntimeException $e) {
                  if ($e->getCode() === self::FORWARD) {
                      return $this->response;
                  } else {
                      throw $e;
                  }
              }
          }
  
          if ($throwException) {
              throw $this->buildException($notFound);
          } else {
              return $notFound;
          }
      }
code_tokens: public function dispatch ( $ controller , $ action = null , array $ params = array ( ) , $ throwException = true ) { $ notFound = array ( ) ; $ action || $ action = $ this -> defaultAction ; $ classes = $ this -> getControllerClasses ( $ controller ) ; foreach ( $ classes as $ class ) { if ( ! class_exists ( $ class ) ) { $ notFound [ 'controllers' ] [ $ controller ] [ ] = $ class ; continue ; } if ( ! $ this -> isActionAvailable ( $ class , $ action ) ) { $ notFound [ 'actions' ] [ $ action ] [ $ controller ] [ ] = $ class ; continue ; } // Find out existing controller and action $ this -> setController ( $ controller ) ; $ this -> setAction ( $ action ) ; $ this -> request -> set ( $ params ) ; try { $ instance = $ this -> getControllerInstance ( $ class ) ; return $ this -> execute ( $ instance , $ action ) ; } catch ( \ RuntimeException $ e ) { if ( $ e -> getCode ( ) === self :: FORWARD ) { return $ this -> response ; } else { throw $ e ; } } } if ( $ throwException ) { throw $ this -> buildException ( $ notFound ) ; } else { return $ notFound ; } }
docstring: Dispatch by specified controller and action
  
  @param string $controller The name of controller
  @param null|string $action The name of action
  @param array $params The request parameters
  @param bool $throwException Whether throw exception when application not found
  @return array|Response
docstring_tokens: Dispatch by specified controller and action