Beispiel #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');
 }
Beispiel #2
0
 public function run(Filesystem $fs)
 {
     $routes = [];
     foreach ($fs->listClasses('Controllers') as $class) {
         $nick = substr(strtolower($class), 12);
         $methods = (new ReflectionClass($class))->getMethods(ReflectionMethod::IS_PUBLIC);
         foreach ($methods as $method) {
             if ($method->getName() != 'index') {
                 $routes[] = $nick . '/' . $method->getName();
             } else {
                 $routes[] = $nick;
             }
         }
     }
     $jobs = [];
     foreach ($fs->listClasses('Jobs') as $class) {
         $jobs[] = str_replace('\\', '.', substr(strtolower($class), 5));
     }
     return compact('routes', 'jobs');
 }
Beispiel #3
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;
     }
 }