diff --git a/src/Commands/ScaffoldMakeCommand.php b/src/Commands/ScaffoldMakeCommand.php index a41400f..5062e1c 100755 --- a/src/Commands/ScaffoldMakeCommand.php +++ b/src/Commands/ScaffoldMakeCommand.php @@ -2,7 +2,6 @@ namespace Summerblue\Generator\Commands; -use Illuminate\Console\DetectsApplicationNamespace; use Illuminate\Console\Command; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Input; @@ -23,7 +22,7 @@ class ScaffoldMakeCommand extends Command { - use DetectsApplicationNamespace, MakerTrait; + use MakerTrait; /** * The console command name! @@ -69,7 +68,6 @@ public function __construct(Filesystem $files) { parent::__construct(); - $this->files = $files; $this->composer = app()['composer']; } @@ -342,4 +340,20 @@ public function getObjName($config = 'Name') return $names[$config]; } + + // AppNamespaceDetectorTrait and DetectsApplicationNamespace compatibility + protected function getAppNamespace() + { + $composer = json_decode(file_get_contents(base_path().'/composer.json'), true); + + foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) + { + foreach ((array) $path as $pathChoice) + { + if (realpath(app_path()) == realpath(base_path().'/'.$pathChoice)) return $namespace; + } + } + + throw new RuntimeException("Unable to detect application namespace."); + } }