/** * @param string $routesFile * @param boolean $public Default public setting * @param boolean $sessions Default sessions setting * @throws PlinthException */ public function loadRoutes($routesFile, $public, $sessions) { if (!file_exists($routesFile)) { throw new PlinthException('Add routing.json to your application config'); } $routes = json_decode(file_get_contents($routesFile), true); if (!is_array($routes)) { throw new PlinthException('Cannot parse routing.json config'); } foreach ($routes as $routeName => $routeInfo) { $newroute = new Route(array('name' => $routeName) + $routeInfo, $this->Main(), $public, $sessions); $this->_routes[$routeName] = $newroute; if ($newroute->isDefault()) { if ($this->_defaultRoute !== false) { throw new PlinthException('You can only define 1 default route'); } $this->_defaultRoute = $newroute; } } }