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.
$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();
+ }
+ }
+ }
}
}