/** * @param string $module * @param string $controller * @throws \T4\Core\Exception * @return \T4\Mvc\Controller */ public function createController($module = null, $controller) { if (!$this->existsController($module ?: null, $controller)) { throw new Exception('Controller ' . $controller . ' does not exist'); } if (empty($module)) { $controllerClass = '\\App\\Controllers\\' . $controller; } else { $controllerClass = '\\App\\Modules\\' . ucfirst($module) . '\\Controllers\\' . ucfirst($controller); } $controller = new $controllerClass(); $view = new View('twig', $controller->getTemplatePaths()); $controller->view = $view; $view->setController($controller); return $controller; }