/** * Do all the setup * * @return $this */ public function run() { /* Set the basedir on paths */ $this->path->setBasedir(BASEDIR); /* Load all known Config files now that we know the baseDir */ $this->hook->trigger('parable_config_load_before'); $this->config->load(); $this->hook->trigger('parable_config_load_after', $this->config); /* Start the session if session.autoEnable is true */ if ($this->config->get('session.autoEnable') !== false) { $this->hook->trigger('parable_session_start_before'); $this->values->session->start(); $this->hook->trigger('parable_session_start_after', $this->values->session); } /* Build the base Url */ $this->url->buildBaseurl(); /* Load the routes */ $this->loadRoutes(); /* Get the current url */ $currentUrl = $this->url->getCurrentUrl(); /* Load the config */ if ($this->config->get('database.type')) { $this->database->setConfig($this->config->get('database')); } /* See if there's an init directory defined in the config */ if ($this->config->get('initLocations')) { $this->loadInits(); } /* And try to match the route */ $this->hook->trigger('parable_route_match_before', $currentUrl); $route = $this->router->matchCurrentRoute(); $this->hook->trigger('parable_route_match_after', $route); if ($route) { $this->hook->trigger('parable_http_200', $route); $this->dispatcher->dispatch($route); } else { $this->response->setHttpCode(404); $this->hook->trigger('parable_http_404', $currentUrl); } $this->hook->trigger('parable_response_send'); $this->response->send(); return $this; }
/** * @param string $name * @param array $parameters * * @return string */ public function getFullRouteUrlByName($name, $parameters = []) { return $this->url->getUrl($this->router->getRouteUrlByName($name, $parameters)); }
/** * Take the current url and try to match it. * * @return \Parable\Routing\Route|null */ public function matchCurrentRoute() { return $this->matchRoute($this->url->getCurrentUrl()); }