/** * Controller constructor. * @param Request|NULL $request */ function __construct(Request $request = NULL) { $this->request = is_null($request) ? Request::getInstance() : $request; $this->config = Config::getInstance(); $this->router = new Router(); $this->route = $this->router; $this->load = new Load(); $this->startConnection(); $this->checkPermission(); Model::$controller = $this; }
/** * * Construtor do Router * * @param Request $request Objeto da Requisição * * @param array|null $routes * * @return void * */ function __construct($routes = NULL) { if (empty(self::$request)) { self::$request = Request::getInstance(); } if (empty(self::$config)) { self::$config = Config::getInstance(); } if (!empty($routes)) { if (is_array($routes)) { foreach ($routes as $i => $route) { self::register($route); } } else { self::register($routes); } } $this->matcher = new Matcher(); self::$instance = $this; }
private static function Error($message = NULL) { if (class_exists('\\Controller\\ErrorController')) { $app = new \Controller\ErrorController(Request::getInstance()); return $app->index($message); } else { return 'Error: ' . $message; } }
public function request() { return Request::getInstance(); }