/**
  * Bootstrap 引导程序
  * @param  \CatLib\Constraint\Base\IApplication $app
  * @return void
  */
 public function bootstrap(IApplication $app)
 {
     $env = $app["env"];
     if (is_array($env["app_aliases"])) {
         $app->aliases($env["app_aliases"]);
     }
 }
Example #2
0
 /**
  * Bootstrap 服务引导程序
  * @param  \CatLib\Constraint\Base\IApplication $app 应用程序实例
  * @return void
  */
 public function bootstrap(IApplication $app)
 {
     $env = $app->make("env");
     foreach ($env["providers"] as $val) {
         $app->register($val);
     }
 }
Example #3
0
 /**
  * 调度到用户协议层
  * @param CatLib\Constraint\Support\IController $controller 控制器
  * @param string $method 调用函数名称
  */
 protected function dispatchToUser(IProtoController $controller, $method)
 {
     return function (IRequest $request) use($controller, $method) {
         $response = $this->app->call([$controller, $method]);
         if ($response == null) {
             $response = $this->response;
         }
         return (new Pipeline($this->app))->send($response)->through($this->getDecorator($controller))->query(function ($response) {
             return $response;
         });
     };
 }
Example #4
0
 /**
  * 准备数据库链接实例
  *
  * @param  \CatLib\Database\Connections\Connection  $connection
  * @return \CatLib\Database\Connections\Connection
  */
 protected function prepare(Connection $connection)
 {
     if (isset($this->app['env']['database']['fetch'])) {
         $connection->setFetchMode($this->app['env']['database']['fetch']);
     }
     if ($this->app->isExists('events')) {
         $connection->setEventDispatcher($this->app['events']);
     }
     $connection->setReconnector(function ($connection) {
         $this->reconnect($connection->getName());
     });
     return $connection;
 }
Example #5
0
 /**
  * Bootstrap 引导程序
  * @param  \CatLib\Constraint\Base\IApplication $app
  * @return void
  */
 public function bootstrap(IApplication $app)
 {
     $this->configPath = [$app->path() . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'config', $app->path() . DIRECTORY_SEPARATOR . 'config', $app->applicationPath() . DIRECTORY_SEPARATOR . 'config'];
     $this->autoLoadPath = [$app->path() . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'autoload', $app->path() . DIRECTORY_SEPARATOR . 'autoload', $app->applicationPath() . DIRECTORY_SEPARATOR . 'autoload'];
     $app->instance('config', $config = new Repository());
     $app->instance('env', $config);
     if (realpath($app->applicationPath() . DIRECTORY_SEPARATOR . ".env") != null) {
         (new Dotenv($app->applicationPath() . DIRECTORY_SEPARATOR, '.env'))->load();
     }
     $this->loadConfigurationFiles($config);
     $this->loadAutoLoad();
 }