Exemplo n.º 1
0
 /**
  * Get the classes that should be combined and compiled.
  *
  * @return array
  */
 protected function getClassFiles()
 {
     $core = $this->filesKey(array_map('url_trimmer', require __DIR__ . '/Optimize/config.php'));
     $files = array_merge($core, $this->filesKey(array_map('url_trimmer', (array) config('compile.files', []))));
     foreach ((array) config('compile.folders', []) as $folder) {
         $files = array_merge($files, $this->filesKey(array_map('url_trimmer', folder_files($folder, true))));
     }
     foreach ((array) config('compile.providers', []) as $provider) {
         $files = array_merge($files, $this->filesKey(array_map('url_trimmer', forward_static_call([$provider, 'compiles']))));
     }
     return array_map('url_trimmer', array_map('realpath', $files));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function slash()
 {
     $factory = new Factory($this);
     $files = folder_files(config()->path->database . 'factories');
     if (!empty($files)) {
         foreach ($files as $file) {
             $this->comment('Processing ' . basename($file) . '...');
             require $file;
             $this->info('Done.' . "\n");
         }
     }
     return $this;
 }
Exemplo n.º 3
0
 protected function loadConfigFolder()
 {
     # - iterate all the base config files and require
     # the files to return an array values
     $base_config_files = iterate_require(folder_files($this->path['config']));
     # - iterate all the environment config files and
     # process the same thing as the base config files
     $env_config_files = iterate_require(folder_files($this->path['config'] . getenv('APP_ENV')));
     # - merge the base config files and the environment
     # config files as one in the our DI 'config'
     config()->merge(new Config($base_config_files));
     config()->merge(new Config($env_config_files));
 }
Exemplo n.º 4
0
 /**
  * Load the configurations.
  *
  * @return $this
  */
 public function loadConfig()
 {
     # let's create an empty config with just an empty
     # array, this is just for us to prepare the config
     $this->di->setShared('config', function () {
         return new Config([]);
     });
     # get the paths and merge the array values to the
     # empty config as we instantiated above
     config(['path' => $this->paths]);
     # now merge the assigned environment
     config(['environment' => $this->getEnvironment()]);
     # iterate all the base config files and require
     # the files to return an array values
     $base_config_files = iterate_require(folder_files($this->paths['config']));
     # iterate all the environment config files and
     # process the same thing as the base config files
     $env_config_files = iterate_require(folder_files(url_trimmer($this->paths['config'] . '/' . $this->getEnvironment())));
     # merge the base config files and the environment
     # config files as one in the our DI 'config'
     config($base_config_files);
     config($env_config_files);
     return $this;
 }
Exemplo n.º 5
0
 /**
  * This loads the environment.
  *
  * @return \Clarity\Console\Brood
  */
 protected function loadEnv()
 {
     $env = $this->getInput()->getOption('env');
     $used_env = '';
     $folder = '';
     if (config('environment')) {
         $folder = $used_env = config('environment');
     }
     if ($env !== null) {
         config(['old_environment' => config('environment')]);
         config(['environment' => $env]);
         $folder = $used_env = $env;
     }
     $folder_path = url_trimmer(config()->path->config . '/' . $folder);
     if (file_exists($folder_path) === false) {
         $this->error("Config Folder [{$used_env}] not found.");
     }
     config(iterate_require(folder_files($folder_path)), $merge = false);
     return $this;
 }
Exemplo n.º 6
0
 /**
  * Get all the files from assigned path.
  *
  * @param string $path The path to be iterated
  * @return mixed
  */
 function folder_files($path, $sub_dir = false)
 {
     if (file_exists($path) === false) {
         return [];
     }
     $iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
     $files = [];
     foreach ($iterator as $item) {
         if ($item->isDir()) {
             if ($sub_dir === true) {
                 $tmp_files = folder_files($item->getPathName(), true);
                 $files = array_merge($files, $tmp_files);
             }
             continue;
         }
         $files[] = $item->getPathName();
     }
     return $files;
 }