/** * Returns the active database connection * * @return \Opis\Database\Connection */ public static function getConnection() { if (static::$connection === null) { return static::$app->connection(); } return static::$app->collect('Connections')->get(static::$connection); }
/** * 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); }
/** * Route path * * @param \Opis\HttpRouting\Path $path * * @return mixed */ public function route(BasePath $path) { $router = new AliasRouter($this->app->collect('RouteAliases')); $alias = $router->route(new AliasPath($path->path())); if ($alias !== null) { $path = new Path((string) $alias, $path->domain(), $path->method(), $path->isSecure(), $path->request()); } $this->path = $path; $result = parent::route($path); $response = $path->request()->response(); $response->body($result); $response->send(); return $result; }
/** * Get a list of commands * * @return array */ public function commands() { $commands = array(); $list = $this->app->collect('Commands')->getList(); foreach ($list as $name => $builder) { try { $command = call_user_func_array($builder, array()); if ($command instanceof Command) { $command->setApp($this->app); $commands[$name] = $command; } } catch (Excepion $e) { } } return $commands; }
/** * Constructor * * @param \Opis\Colibri\Application $app */ public function __construct(Application $app) { $this->app = $this->param = $app; parent::__construct($app->collect('Views'), $app->collect('ViewEngines')); }
/** * Constructor * * @param \Opis\Colibri\Application $app */ public function __construct(Application $app) { $this->app = $app; parent::__construct($app->collect('Validators')->getList()); }