public static function handle(\Exception $ex)
 {
     if ($ex->getPrevious() instanceof ConsoleException) {
         Console::error($ex->getMessage());
         return;
     }
     $handles = Settings::load('exception');
     if (isset($handles) && !empty($handles)) {
         foreach ($handles as $key => $value) {
             if (self::recursive($ex, $key)) {
                 if (is_callable($value)) {
                     call_user_func($value, $ex);
                     return;
                 } else {
                     /** @var ExceptionHandle $handle */
                     $handle = DI::get($value);
                     if (isset($handle)) {
                         $handle->handle();
                         return;
                     }
                 }
             }
         }
     }
     throw $ex;
 }
示例#2
0
 public function appStart()
 {
     Command::bind('model', ModelCommand::class);
     Command::bind('migrate', MigrateCommand::class);
     Command::bind('migration', MigrationCommand::class);
     Command::bind('daemon', DaemonCommand::class);
     Command::bind('service', ServiceCommand::class);
     Daemon::bind('idle', IdleDaemon::class);
     Daemon::bind('schedule', ScheduleDaemon::class);
     Settings::load('commands');
     Settings::load('daemons');
     DI::bindSingleton(AuthStorage::class, CacheAuthStorage::class);
 }
示例#3
0
 public function appStart()
 {
     $this->classLoader = new ClassLoader();
     $paths = Settings::load('autoload');
     if (!isset($paths)) {
         $paths = array();
     }
     $paths[] = '/service';
     $paths[] = '/job';
     $paths[] = '/command';
     $paths[] = '/daemon';
     $paths[] = '/module';
     $paths[] = '/models';
     $paths[] = '/test';
     $paths[] = '/database/migration';
     foreach ($paths as $item) {
         $this->classLoader->addPath(App::path('app') . $item);
     }
 }
示例#4
0
 public function appStart()
 {
     Settings::load('inject');
 }
示例#5
0
 private function recordHistory($name)
 {
     $this->history[] = $name;
     Settings::save(App::path('migration_history'), serialize($this->history));
 }
 private function forgetMigration()
 {
     if (!isset($this->args[1])) {
         throw new ConsoleException("Invalid migration argument in [--forget].");
     }
     $selectedIndex = intval($this->args[1]);
     $history = Settings::get(App::path('migration_history'));
     if (isset($history)) {
         $history = unserialize($history);
         if (!empty($history)) {
             $this->history = $history;
             $date = "Unknown datetime";
             foreach ($this->history as $key => $value) {
                 if ($key === $selectedIndex) {
                     unset($this->history[$selectedIndex]);
                     if (preg_match('#^m(?<timestamp>\\d+)#i', $value, $match)) {
                         if (array_key_exists('timestamp', $match)) {
                             $timestamp = intval($match['timestamp']);
                             $date = date("Y-m-d H:i:s", $timestamp);
                         }
                     }
                     Settings::save(App::path('migration_history'), serialize($this->history));
                     Console::line("{$key}.[{$date}][{$value}] has forget.");
                     return;
                 }
             }
             Console::line("Can't find index [{$selectedIndex}].");
             return;
         }
     }
     Console::line("History is empty.");
 }
示例#7
0
 public function appStart()
 {
     Settings::load('module');
 }