Skip to content

Commit

Permalink
Fixed console call method without console.input and console.output.
Browse files Browse the repository at this point in the history
  • Loading branch information
youmingdot committed Jan 31, 2019
1 parent aca2649 commit 1efda09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
7 changes: 7 additions & 0 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ protected function loadCommands()
*/
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
// Share the input and the output, so that we can get them anywhere easily.
$this->laravel->instance('console.input', $input);
$this->laravel->instance('console.output', $output);

$this->laravel->instance('console.command', $command);

parent::doRunCommand($command, $input, $output);

$this->laravel->forgetInstance('console.command');

$this->laravel->forgetInstance('console.input');
$this->laravel->forgetInstance('console.output');
}
}
26 changes: 0 additions & 26 deletions src/Foundation/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use Illuminate\Contracts\Console\Kernel as KernelContract;
use Illuminate\Foundation\Console\Kernel as BaseKernel;
use Lawoole\Console\Application as Artisan;
use Symfony\Component\Console\Output\ConsoleOutput;

class Kernel extends BaseKernel implements KernelContract
{
Expand All @@ -30,31 +29,6 @@ protected function defineConsoleSchedule()
$this->schedule($this->app['schedule']);
}

/**
* {@inheritdoc}
*/
public function handle($input, $output = null)
{
$output = $output ?: new ConsoleOutput;

// Share the input and the output, so that we can get them anywhere easily.
$this->shareIoStream($input, $output);

parent::handle($input, $output);
}

/**
* Share the input stream and output stream with the container.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*/
protected function shareIoStream($input, $output)
{
$this->app->instance('console.input', $input);
$this->app->instance('console.output', $output);
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 1efda09

Please sign in to comment.