/** * Create a new Controller object * * @param string $viewName The name of the view we're getting a Controller for. * @param array $config Optional MVC configuration values for the Controller object. * * @return Controller */ public function controller($viewName, array $config = array()) { try { return parent::controller($viewName, $config); } catch (ControllerNotFound $e) { $magic = new Magic\ControllerFactory($this->container); // Let's pass the section override (if any) $magic->setSection($this->getSection()); return $magic->make($viewName, $config); } }
/** * Make a new scaffolding document * * @param string $requestedClass The requested class, with full qualifier ie Myapp\Site\Controller\Foobar * @param string $viewName The name of the view linked to this controller * * @return bool True on success, false otherwise */ public function make($requestedClass, $viewName) { // Class already exists? Stop here if (class_exists($requestedClass)) { return true; } // I have to magically create the controller class $magic = new ControllerFactory($this->container); $magic->setSection($this->getSection()); $fofController = $magic->make($viewName); /** @var ErectorInterface $erector */ $erector = new ControllerErector($this, $fofController, $viewName); $erector->setSection($this->getSection()); $erector->build(); if (!class_exists($requestedClass)) { return false; } return true; }