mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:34:04 +00:00
Use StringInput instead of ArgvInput so that tenants:run accepts args properly
This commit is contained in:
parent
f955b38e2b
commit
1750297225
1 changed files with 4 additions and 18 deletions
|
|
@ -7,8 +7,8 @@ namespace Stancl\Tenancy\Commands;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
use Stancl\Tenancy\Concerns\HasTenantOptions;
|
use Stancl\Tenancy\Concerns\HasTenantOptions;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
|
||||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||||
|
use Symfony\Component\Console\Input\StringInput;
|
||||||
|
|
||||||
class Run extends Command
|
class Run extends Command
|
||||||
{
|
{
|
||||||
|
|
@ -21,30 +21,16 @@ class Run extends Command
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$argvInput = $this->argvInput();
|
$stringInput = (new StringInput($this->argument('commandname')));
|
||||||
|
|
||||||
tenancy()->runForMultiple($this->getTenants(), function ($tenant) use ($argvInput) {
|
tenancy()->runForMultiple($this->getTenants(), function ($tenant) use ($stringInput) {
|
||||||
$this->components->info("Tenant: {$tenant->getTenantKey()}");
|
$this->components->info("Tenant: {$tenant->getTenantKey()}");
|
||||||
|
|
||||||
$this->getLaravel()
|
$this->getLaravel()
|
||||||
->make(Kernel::class)
|
->make(Kernel::class)
|
||||||
->handle($argvInput, new ConsoleOutput);
|
->handle($stringInput, new ConsoleOutput);
|
||||||
});
|
});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function argvInput(): ArgvInput
|
|
||||||
{
|
|
||||||
/** @var string $commandName */
|
|
||||||
$commandName = $this->argument('commandname');
|
|
||||||
|
|
||||||
// Convert string command to array
|
|
||||||
$subCommand = explode(' ', $commandName);
|
|
||||||
|
|
||||||
// Add "artisan" as first parameter because ArgvInput expects "artisan" as first parameter and later removes it
|
|
||||||
array_unshift($subCommand, 'artisan');
|
|
||||||
|
|
||||||
return new ArgvInput($subCommand);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue