/** * Get router (override) * * @return \Opis\Routing\Router */ protected function getRouter() { if ($this->router === null) { $specials = array('app' => $this->app, 'request' => $this->app->request(), 'response' => $this->app->response(), 't' => $this->app->getTranslator(), 'lang' => $this->app->getTranslator()->getLanguage(), 'view' => $this); $this->router = new Router($this->collection, null, $this->getFilters(), $specials); } return $this->router; }
/** * Get the HTTP path to a module's resurce * * @return string */ public function resource($name, $absolute = true) { $path = '/assets/module/' . strtolower($this->module) . '/' . trim($name, '/'); if ($absolute) { $path = $this->app->request()->uriForPath($path); } return $path; }
/** * Constructor * * @param \Opis\Colibri\Application $app */ public function __construct(Application $app) { $this->app = $app; $specials = array('app' => $app, 'request' => $app->request(), 'response' => $app->response(), 't' => $app->getTranslator(), 'lang' => $app->getTranslator()->getLanguage(), 'view' => $app->getViewRouter()); parent::__construct($app->collect('Routes'), $app->collect('Dispatchers'), null, $specials); $this->getRouteCollection()->notFound(function ($path) use($app) { return new NotFound($app->view('error.404', array('path' => $path))); })->accessDenied(function ($path) use($app) { return new AccessDenied($app->view('error.403', array('path' => $path))); }); $this->getRouteCollection()->setRouter($this); }