From bce143f0d1df293c868257f86b41b5eb0b9159ec Mon Sep 17 00:00:00 2001 From: locopine Date: Thu, 2 Sep 2021 23:28:00 -0300 Subject: [PATCH 1/2] Backup copy ref. tag v2.5 divergent from package downloaded by composer. --- src/Commands/InstallMenuBuilder_v2.5.php | 103 +++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/Commands/InstallMenuBuilder_v2.5.php diff --git a/src/Commands/InstallMenuBuilder_v2.5.php b/src/Commands/InstallMenuBuilder_v2.5.php new file mode 100644 index 0000000..c23e937 --- /dev/null +++ b/src/Commands/InstallMenuBuilder_v2.5.php @@ -0,0 +1,103 @@ +info('Publishing the MenuBuilder assets, database, and config files'); + // Publish only relevant resources on install + $tags = ['menu.seeds', 'menu.config']; + $this->call('vendor:publish', ['--provider' => MenuServiceProvider::class, '--tag' => $tags]); + + $this->info('Migrating the database tables into your application'); + $this->call('migrate', ['--force' => $this->option('force')]); + + $this->info('Dumping the autoloaded files and reloading all new files'); + $composer = $this->findComposer(); + /* $process = new Process($composer . ' dump-autoload'); // Process waits array, as can be seen during the release of the exception: "Symfony\Component\Process\Process::__construct(): Argument #1 ($command) must be of type array, string given" */ + $process = new Process([$composer . ' dump-autoload']); /* Comando passado como array */ + $process->setTimeout(null); // Setting timeout to null to prevent installation from stopping at a certain point in time + $process->setWorkingDirectory(base_path())->run(); + + // Load Permission routes into application's 'routes/web.php' + $this->info('Adding Permission routes to routes/web.php'); + $routes_contents = $filesystem->get(base_path('routes/web.php')); + if (false === strpos($routes_contents, 'MenuBuilder::routes();')) { + $filesystem->append( + base_path('routes/web.php'), + "\n\nRoute::group(['prefix' => config('menu.prefix')], function () {\n MenuBuilder::routes();\n});\n" + ); + } + + // Seeding Dummy Data + $class = 'MenuDatabaseSeeder'; + $file = $this->seedersPath . $class . '.php'; + + if (file_exists($file) && !class_exists($class)) { + require_once $file; + } + with(new $class())->run(); + + $this->info('Seeding Completed'); + } +} From 53f3028e675253aefdf1436f6d8faeb7ee08f020 Mon Sep 17 00:00:00 2001 From: locopine Date: Thu, 2 Sep 2021 23:34:57 -0300 Subject: [PATCH 2/2] Removed extra quote in return of line 53. Execution of the command "composer dump-autoload" passed in array, as required by the "Process" class. --- src/Commands/InstallMenuBuilder.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Commands/InstallMenuBuilder.php b/src/Commands/InstallMenuBuilder.php index 330ae12..f926fb2 100644 --- a/src/Commands/InstallMenuBuilder.php +++ b/src/Commands/InstallMenuBuilder.php @@ -27,10 +27,10 @@ class InstallMenuBuilder extends Command * * @var string */ - protected $seedersPath = __DIR__.'/../../database/seeds/'; + protected $seedersPath = __DIR__ . '/../../database/seeds/'; /** - * Get Option. + * Get Option * * @return array */ @@ -48,10 +48,10 @@ protected function getOptions() */ protected function findComposer() { - if (file_exists(getcwd().'/composer.phar')) { - return '"'.PHP_BINARY.'" '.getcwd().'/composer.phar'; + if (file_exists(getcwd() . '/composer.phar')) { + /* return '"' . PHP_BINARY . '" ' . getcwd() . '/composer.phar'; // Leading quotes causing duplicate returns (origin) */ + return PHP_BINARY . '" ' . getcwd() . '/composer.phar'; /* Removed leading quotation marks */ } - return 'composer'; } @@ -74,7 +74,8 @@ public function handle(Filesystem $filesystem) $this->info('Dumping the autoloaded files and reloading all new files'); $composer = $this->findComposer(); - $process = Process::fromShellCommandline($composer.' dump-autoload'); + /* $process = new Process($composer . ' dump-autoload'); // Process waits array, as can be seen during the release of the exception: "Symfony\Component\Process\Process::__construct(): Argument #1 ($command) must be of type array, string given" */ + $process = new Process([$composer . ' dump-autoload']); /* Command passed as array */ $process->setTimeout(null); // Setting timeout to null to prevent installation from stopping at a certain point in time $process->setWorkingDirectory(base_path())->run(); @@ -84,13 +85,13 @@ public function handle(Filesystem $filesystem) if (false === strpos($routes_contents, 'MenuBuilder::routes();')) { $filesystem->append( base_path('routes/web.php'), - "\n\nMenuBuilder::routes();\n" + "\n\nRoute::group(['prefix' => config('menu.prefix')], function () {\n MenuBuilder::routes();\n});\n" ); } // Seeding Dummy Data $class = 'MenuDatabaseSeeder'; - $file = $this->seedersPath.$class.'.php'; + $file = $this->seedersPath . $class . '.php'; if (file_exists($file) && !class_exists($class)) { require_once $file;