Exemple #1
0
 public function run(Filesystem $filesystem, Framework $framework)
 {
     $time = time();
     $namespace = date('FY', $time);
     if (!is_array($this->name)) {
         $this->name = explode(' ', $this->name);
     }
     $class = '';
     foreach ($this->name as $piece) {
         $class .= ucfirst($piece);
     }
     $template = $framework->getPath('resources/templates/migration.php');
     ob_start();
     include $template;
     $contents = ob_get_clean();
     $path = $filesystem->getPath('resources/migrations');
     if (!is_dir($path)) {
         mkdir($path);
     }
     $path = $filesystem->getPath('resources/migrations/' . date('Ym', $time));
     if (!is_dir($path)) {
         mkdir($path);
     }
     $filename = $path . '/' . $class . '.php';
     file_put_contents($filename, $contents);
     return compact('filename', 'namespace', 'class');
 }
Exemple #2
0
 public function __construct(Filesystem $fs, Converter $converter)
 {
     $this->converter = $converter;
     if ($fs->exists('.env')) {
         $dotenv = new Dotenv($fs->getPath());
         $dotenv->load();
     }
     foreach ($fs->listFiles('resources/config') as $file) {
         $values = $this->converter->toObject(include $fs->getPath("resources/config/{$file}"));
         $current = $this;
         $name = substr($file, 0, -4);
         if (stristr($name, '/')) {
             $namespace = explode('/', $name);
             $name = array_pop($namespace);
             foreach ($namespace as $key) {
                 $current->{$key} = (object) [];
                 $current = $current->{$key};
             }
         }
         $current->{$name} = $values;
     }
 }