/**
  * dispatch the controller
  *
  * @throws ControllerException
  * @return \Anonym\Components\Route\Controller
  */
 public function dispatch()
 {
     $name = $this->generateClassName($this->namespace, $this->class);
     // the controller instance
     $controller = App::make($name);
     if ($controller instanceof Controller) {
         // register the parameters
         $controller->setParameters(ParameterBag::getParameters());
         // return the instance
         return $controller;
     } else {
         throw new ControllerException(sprintf('%s is not a controller', $name));
     }
 }
Пример #2
0
 /**
  * Call the method of controller
  *
  * @param Controller $controller the instance of controller
  * @param string $method the name of a controller method
  * @return mixed
  */
 private function callControllerMethod(Controller $controller, $method)
 {
     return app()->call([$controller, $method], ParameterBag::getParameters());
 }