]> _ Git - cubist_cms-back.git/commitdiff
#2783
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 May 2019 16:33:49 +0000 (18:33 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 May 2019 16:33:49 +0000 (18:33 +0200)
src/app/Console/Commands/MagicCubistCommand.php

index b6fe859c232ab8324c9fe6b64f690697cc097d0c..9425997b121a057c39690bc857d8ddeb4e26560f 100644 (file)
@@ -3,11 +3,12 @@
 
 namespace Cubist\Backpack\app\Console\Commands;
 
+use Backpack\Base\app\Console\Commands\Install;
+use Cubist\Backpack\app\Magic\Models\CubistMagicModelAbstract;
 use Cubist\Util\Files\Files;
-use Illuminate\Support\Facades\Artisan;
-use Illuminate\Console\Command;
+use Cubist\Util\PHP;
 
-class MagicCubistCommand extends Command
+class MagicCubistCommand extends Install
 {
     /**
      * The name and signature of the console command.
@@ -35,15 +36,26 @@ class MagicCubistCommand extends Command
         $magics = [];
         foreach ($iterator as $item) {
             /** @var $item \SplFileInfo */
-            if ($item->isDir() && $item->getFilename() == 'cubistmagic') {
+            if ($item->isDir() && $item->getFilename() == 'CubistMagic') {
                 $this->_handleMagicFolder($item);
             }
         }
         $this->executeProcess('composer dump-autoload');
     }
 
-    protected function _handleMagicFolder(\SplFileInfo $item)
+    protected function _handleMagicFolder(\SplFileInfo $folder)
     {
-        $this->line('Handling ' . $item->getPath());
+        $this->line('Handling folder ' . $folder);
+        $iterator = Files::getDirectoryIterator($folder, true);
+        foreach ($iterator as $item) {
+            /** @var $item \SplFileInfo */
+            if ($item->isFile() && $item->getExtension() == 'php') {
+                $class = PHP::instanciateClassInFile($item);
+                if ($class instanceof CubistMagicModelAbstract) {
+                    $this->line('Generate code of ' . get_class($class));
+                    $class->generateCode();
+                }
+            }
+        }
     }
 }