From d1b588fe195cdc7be6973b501de32555b0c89b09 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 22 May 2019 18:33:49 +0200 Subject: [PATCH] #2783 --- .../Console/Commands/MagicCubistCommand.php | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/app/Console/Commands/MagicCubistCommand.php b/src/app/Console/Commands/MagicCubistCommand.php index b6fe859..9425997 100644 --- a/src/app/Console/Commands/MagicCubistCommand.php +++ b/src/app/Console/Commands/MagicCubistCommand.php @@ -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(); + } + } + } } } -- 2.39.5