Beispiel #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     zbase()->setConsoleCommand($this);
     $phpCommand = env('ZBASE_PHP_COMMAND', 'php');
     $packages = zbase()->packages();
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\TestCommandInterface) {
                 $this->info($this->signature . '.pre - ' . $packageName);
                 $zbase->testCommand($phpCommand, ['test.pre' => true, 'command' => $this]);
             }
         }
     }
     $commands = [];
     if (!empty($commands)) {
         foreach ($commands as $command) {
             if ($command instanceof \Closure) {
                 $command();
             }
         }
     }
     zbase_package('zbase')->testCommand($phpCommand, ['test.post' => true, 'command' => $this]);
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\TestCommandInterface) {
                 $this->info($this->signature . '.post - ' . $packageName);
                 $zbase->testCommand($phpCommand, ['test.post' => true, 'command' => $this]);
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     zbase()->setConsoleCommand($this);
     $phpCommand = env('ZBASE_PHP_COMMAND', 'php');
     $packages = zbase()->packages();
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\AssetsCommandInterface) {
                 $this->info($this->signature . '.pre - ' . $packageName);
                 $zbase->assetsCommand($phpCommand, ['assets.pre' => true, 'command' => $this]);
             }
         }
     }
     echo shell_exec($phpCommand . ' artisan vendor:publish --tag=public --force');
     $commands = [];
     if (!empty($commands)) {
         foreach ($commands as $command) {
             if ($command instanceof \Closure) {
                 $command();
             } else {
                 echo shell_exec($phpCommand . ' artisan ' . $command);
             }
         }
     }
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\AssetsCommandInterface) {
                 $this->info($this->signature . '.post - ' . $packageName);
                 $zbase->assetsCommand($phpCommand, ['assets.post' => true, 'command' => $this]);
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     zbase_maintenance_set();
     zbase()->setConsoleCommand($this);
     $phpCommand = env('ZBASE_PHP_COMMAND', 'php');
     $packages = zbase()->packages();
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\MigrateCommandInterface) {
                 $this->info($this->signature . '.pre - ' . $packageName);
                 $zbase->migrateCommand($phpCommand, ['migrate.pre' => true, 'command' => $this]);
             }
         }
     }
     \File::cleanDirectory(database_path() . '/migrations');
     \File::cleanDirectory(database_path() . '/seeds');
     \File::cleanDirectory(database_path() . '/factories');
     \File::cleanDirectory(storage_path() . '/zbase');
     \File::cleanDirectory(storage_path() . '/framework/cache');
     \File::cleanDirectory(storage_path() . '/framework/views');
     \File::cleanDirectory(storage_path() . '/logs');
     echo shell_exec($phpCommand . ' artisan vendor:publish --tag=migrations --force');
     echo shell_exec($phpCommand . ' artisan optimize');
     echo shell_exec($phpCommand . ' artisan migrate:refresh --seed --force');
     $commands = [];
     // zbase()->commands('migrate');
     if (!empty($commands)) {
         foreach ($commands as $command) {
             if ($command instanceof \Closure) {
                 $command();
             } else {
                 echo shell_exec($phpCommand . ' artisan ' . $command);
             }
         }
     }
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\MigrateCommandInterface) {
                 $this->info($this->signature . '.post - ' . $packageName);
                 $zbase->migrateCommand($phpCommand, ['migrate.post' => true, 'command' => $this]);
             }
         }
     }
     zbase_maintenance_unset();
 }
Beispiel #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     zbase()->setConsoleCommand($this);
     $phpCommand = env('ZBASE_PHP_COMMAND', 'php');
     $packages = zbase()->packages();
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\ClearCommandInterface) {
                 $this->info($this->signature . '.pre - ' . $packageName);
                 $zbase->clearCommand($phpCommand, ['clear.pre' => true, 'command' => $this]);
             }
         }
     }
     echo shell_exec($phpCommand . ' artisan clear-compiled');
     echo shell_exec($phpCommand . ' artisan cache:clear');
     echo shell_exec($phpCommand . ' artisan view:clear');
     echo shell_exec($phpCommand . ' artisan config:clear');
     echo shell_exec($phpCommand . ' artisan route:clear');
     \File::cleanDirectory(zbase_storage_path('tmp/images'));
     \File::cleanDirectory(zbase_storage_path(zbase_tag() . '_tmp/images'));
     $commands = [];
     // zbase()->commands('clear');
     if (!empty($commands)) {
         foreach ($commands as $command) {
             if ($command instanceof \Closure) {
                 $command();
             } else {
                 echo shell_exec($phpCommand . ' artisan ' . $command);
             }
         }
     }
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $zbase = zbase_package($packageName);
             if ($zbase instanceof Interfaces\ClearCommandInterface) {
                 $this->info($this->signature . '.post - ' . $packageName);
                 $zbase->clearCommand($phpCommand, ['clear.post' => true, 'command' => $this]);
             }
         }
     }
 }
Beispiel #5
0
 /**
  * Return the merged configuration of packages
  *
  * @return array
  */
 public function getPackagesMergedConfigs()
 {
     $packages = $this->packages();
     $configs = [];
     if (!empty($packages)) {
         foreach ($packages as $packageName) {
             $configFiles = zbase_package($packageName)->config();
             $packagePath = zbase_package($packageName)->path();
             if (is_array($configFiles)) {
                 foreach ($configFiles as $configFile) {
                     if (file_exists($configFile)) {
                         $configs = array_replace_recursive($configs, require $configFile);
                     }
                 }
             } else {
                 $configs = array_replace_recursive($configs, require $configFiles);
             }
         }
     }
     return $configs;
 }
 public function boot()
 {
     parent::boot();
     $this->loadViewsFrom(__DIR__ . '/../resources/views', zbase_tag());
     $this->loadViewsFrom(__DIR__ . '/../modules', zbase_tag() . 'modules');
     if (!zbase_is_testing()) {
         $this->mergeConfigFrom(__DIR__ . '/../config/config.php', zbase_tag());
         $packages = zbase()->packages();
         if (!empty($packages)) {
             foreach ($packages as $packageName) {
                 $packagePath = zbase_package($packageName)->path();
                 $this->loadViewsFrom($packagePath . 'modules', $packageName . 'modules');
                 if (zbase_file_exists($packagePath . 'resources/views')) {
                     $this->loadViewsFrom($packagePath . 'resources/views', $packageName);
                 }
                 if (zbase_file_exists($packagePath . 'resources/assets')) {
                     $this->publishes([$packagePath . 'resources/assets' => zbase_public_path(zbase_path_asset($packageName))], 'public');
                 }
                 if (zbase_file_exists($packagePath . '/Http/Controllers/Laravel/routes.php')) {
                     require $packagePath . '/Http/Controllers/Laravel/routes.php';
                 }
             }
         }
         $this->app['config'][zbase_tag()] = array_replace_recursive($this->app['config'][zbase_tag()], zbase()->getPackagesMergedConfigs());
     } else {
         $this->loadViewsFrom(__DIR__ . '/../tests/resources/views', zbase_tag() . 'test');
         copy(__DIR__ . '/../config/entities/user.php', __DIR__ . '/../tests/config/entities/user.php');
         $this->mergeConfigFrom(__DIR__ . '/../tests/config/config.php', zbase_tag());
     }
     $this->publishes([__DIR__ . '/../resources/assets' => zbase_public_path(zbase_path_asset())], 'public');
     $this->publishes([__DIR__ . '/../database/migrations' => base_path('database/migrations'), __DIR__ . '/../database/seeds' => base_path('database/seeds'), __DIR__ . '/../database/factories' => base_path('database/factories')], 'migrations');
     $this->app['config']['database.connections.mysql.prefix'] = zbase_db_prefix();
     $this->app['config']['auth.providers.users.model'] = get_class(zbase_entity('user'));
     $this->app['config']['auth.passwords.users.table'] = zbase_config_get('entity.user_tokens.table.name');
     $this->app['config']['auth.passwords.users.email'] = zbase_view_file_contents('auth.password.email.password');
     require __DIR__ . '/Http/Controllers/Laravel/routes.php';
     zbase()->prepareWidgets();
     /**
      * Validator to check for account password
      * @TODO should be placed somewhere else other than here, and just call
      */
     \Validator::extend('accountPassword', function ($attribute, $value, $parameters, $validator) {
         if (zbase_auth_has()) {
             $user = zbase_auth_user();
             if (zbase_bcrypt_check($value, $user->password)) {
                 return true;
             }
         }
         return false;
     });
     \Validator::replacer('accountPassword', function ($message, $attribute, $rule, $parameters) {
         return _zt('Account password don\'t match.');
     });
     /**
      *
      */
     \Validator::extend('passwordStrengthCheck', function ($attribute, $value, $parameters, $validator) {
         //			if(!preg_match("#[0-9]+#", $value))
         //			{
         //				//$errors[] = "Password must include at least one number!";
         //				return false;
         //			}
         //
         //			if(!preg_match("#[a-zA-Z]+#", $value))
         //			{
         //				//$errors[] = "Password must include at least one letter!";
         //				return false;
         //			}
         return true;
     });
     \Validator::replacer('passwordStrengthCheck', function ($message, $attribute, $rule, $parameters) {
         return _zt('New password is too weak.');
     });
     // dd(zbase_config_get('email.account-noreply.email'));
     // dd(\Zbase\Utility\Service\Flickr::findByTags(['heavy equipment','dozers','loader']));
 }