original_string: public function resolve($route, $req, $res, array $args)
      {
          $result = false;
          if (is_array($route) || is_string($route)) {
              // method name and controller supplied
              if (is_string($route) && $req->params('controller')) {
                  $route = [$req->params('controller'), $route];
              // method name supplied
              } elseif (is_string($route)) {
                  $route = [$this->defaultController, $route];
              // no method name? fallback to the index() method
              } elseif (count($route) == 1) {
                  $route[] = $this->defaultAction;
              }
  
              list($controller, $method) = $route;
  
              $controller = $this->namespace.'\\'.$controller;
  
              if (!class_exists($controller)) {
                  throw new \Exception("Controller does not exist: $controller");
              }
  
              $controllerObj = new $controller();
  
              // give the controller access to the DI container
              if (method_exists($controllerObj, 'setApp')) {
                  $controllerObj->setApp($this->app);
              }
  
              // collect any preset route parameters
              if (isset($route[2])) {
                  $params = $route[2];
                  $req->setParams($params);
              }
  
              $result = $controllerObj->$method($req, $res, $args);
          } elseif (is_callable($route)) {
              $result = call_user_func($route, $req, $res, $args);
          }
  
          if ($result instanceof View) {
              $res->render($result);
          }
  
          return $res;
      }
code: public function resolve($route, $req, $res, array $args)
      {
          $result = false;
          if (is_array($route) || is_string($route)) {
              // method name and controller supplied
              if (is_string($route) && $req->params('controller')) {
                  $route = [$req->params('controller'), $route];
              // method name supplied
              } elseif (is_string($route)) {
                  $route = [$this->defaultController, $route];
              // no method name? fallback to the index() method
              } elseif (count($route) == 1) {
                  $route[] = $this->defaultAction;
              }
  
              list($controller, $method) = $route;
  
              $controller = $this->namespace.'\\'.$controller;
  
              if (!class_exists($controller)) {
                  throw new \Exception("Controller does not exist: $controller");
              }
  
              $controllerObj = new $controller();
  
              // give the controller access to the DI container
              if (method_exists($controllerObj, 'setApp')) {
                  $controllerObj->setApp($this->app);
              }
  
              // collect any preset route parameters
              if (isset($route[2])) {
                  $params = $route[2];
                  $req->setParams($params);
              }
  
              $result = $controllerObj->$method($req, $res, $args);
          } elseif (is_callable($route)) {
              $result = call_user_func($route, $req, $res, $args);
          }
  
          if ($result instanceof View) {
              $res->render($result);
          }
  
          return $res;
      }
code_tokens: public function resolve ( $ route , $ req , $ res , array $ args ) { $ result = false ; if ( is_array ( $ route ) || is_string ( $ route ) ) { // method name and controller supplied if ( is_string ( $ route ) && $ req -> params ( 'controller' ) ) { $ route = [ $ req -> params ( 'controller' ) , $ route ] ; // method name supplied } elseif ( is_string ( $ route ) ) { $ route = [ $ this -> defaultController , $ route ] ; // no method name? fallback to the index() method } elseif ( count ( $ route ) == 1 ) { $ route [ ] = $ this -> defaultAction ; } list ( $ controller , $ method ) = $ route ; $ controller = $ this -> namespace . '\\' . $ controller ; if ( ! class_exists ( $ controller ) ) { throw new \ Exception ( "Controller does not exist: $controller" ) ; } $ controllerObj = new $ controller ( ) ; // give the controller access to the DI container if ( method_exists ( $ controllerObj , 'setApp' ) ) { $ controllerObj -> setApp ( $ this -> app ) ; } // collect any preset route parameters if ( isset ( $ route [ 2 ] ) ) { $ params = $ route [ 2 ] ; $ req -> setParams ( $ params ) ; } $ result = $ controllerObj -> $ method ( $ req , $ res , $ args ) ; } elseif ( is_callable ( $ route ) ) { $ result = call_user_func ( $ route , $ req , $ res , $ args ) ; } if ( $ result instanceof View ) { $ res -> render ( $ result ) ; } return $ res ; }
docstring: Executes a route handler.
  
  @param array|string $route array('controller','method') or array('controller')
  or 'method'
  @param Request      $req
  @param Response     $res
  @param array        $args
  
  @throws Exception when the route cannot be resolved.
  
  @return Response
docstring_tokens: Executes a route handler .