Laravel version update
Laravel version update
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Console;
|
||||
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
@@ -15,6 +16,8 @@ use Symfony\Component\Console\Command\Command as SymfonyCommand;
|
||||
|
||||
class Command extends SymfonyCommand
|
||||
{
|
||||
use Macroable;
|
||||
|
||||
/**
|
||||
* The Laravel application instance.
|
||||
*
|
||||
@@ -57,6 +60,13 @@ class Command extends SymfonyCommand
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* Indicates whether the command should be shown in the Artisan command list.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $hidden = false;
|
||||
|
||||
/**
|
||||
* The default verbosity of output commands.
|
||||
*
|
||||
@@ -70,10 +80,10 @@ class Command extends SymfonyCommand
|
||||
* @var array
|
||||
*/
|
||||
protected $verbosityMap = [
|
||||
'v' => OutputInterface::VERBOSITY_VERBOSE,
|
||||
'vv' => OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
'vvv' => OutputInterface::VERBOSITY_DEBUG,
|
||||
'quiet' => OutputInterface::VERBOSITY_QUIET,
|
||||
'v' => OutputInterface::VERBOSITY_VERBOSE,
|
||||
'vv' => OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
'vvv' => OutputInterface::VERBOSITY_DEBUG,
|
||||
'quiet' => OutputInterface::VERBOSITY_QUIET,
|
||||
'normal' => OutputInterface::VERBOSITY_NORMAL,
|
||||
];
|
||||
|
||||
@@ -93,8 +103,13 @@ class Command extends SymfonyCommand
|
||||
parent::__construct($this->name);
|
||||
}
|
||||
|
||||
// Once we have constructed the command, we'll set the description and other
|
||||
// related properties of the command. If a signature wasn't used to build
|
||||
// the command we'll set the arguments and the options on this command.
|
||||
$this->setDescription($this->description);
|
||||
|
||||
$this->setHidden($this->hidden);
|
||||
|
||||
if (! isset($this->signature)) {
|
||||
$this->specifyParameters();
|
||||
}
|
||||
@@ -109,8 +124,11 @@ class Command extends SymfonyCommand
|
||||
{
|
||||
list($name, $arguments, $options) = Parser::parse($this->signature);
|
||||
|
||||
parent::__construct($name);
|
||||
parent::__construct($this->name = $name);
|
||||
|
||||
// After parsing the signature we will spin through the arguments and options
|
||||
// and set them on this command. These will already be changed into proper
|
||||
// instances of these "InputArgument" and "InputOption" Symfony classes.
|
||||
foreach ($arguments as $argument) {
|
||||
$this->getDefinition()->addArgument($argument);
|
||||
}
|
||||
@@ -148,11 +166,9 @@ class Command extends SymfonyCommand
|
||||
*/
|
||||
public function run(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->input = $input;
|
||||
|
||||
$this->output = new OutputStyle($input, $output);
|
||||
|
||||
return parent::run($input, $output);
|
||||
return parent::run(
|
||||
$this->input = $input, $this->output = new OutputStyle($input, $output)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,9 +180,7 @@ class Command extends SymfonyCommand
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$method = method_exists($this, 'handle') ? 'handle' : 'fire';
|
||||
|
||||
return $this->laravel->call([$this, $method]);
|
||||
return $this->laravel->call([$this, 'handle']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,11 +192,11 @@ class Command extends SymfonyCommand
|
||||
*/
|
||||
public function call($command, array $arguments = [])
|
||||
{
|
||||
$instance = $this->getApplication()->find($command);
|
||||
|
||||
$arguments['command'] = $command;
|
||||
|
||||
return $instance->run(new ArrayInput($arguments), $this->output);
|
||||
return $this->getApplication()->find($command)->run(
|
||||
$this->createInputFromArguments($arguments), $this->output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,11 +208,26 @@ class Command extends SymfonyCommand
|
||||
*/
|
||||
public function callSilent($command, array $arguments = [])
|
||||
{
|
||||
$instance = $this->getApplication()->find($command);
|
||||
|
||||
$arguments['command'] = $command;
|
||||
|
||||
return $instance->run(new ArrayInput($arguments), new NullOutput);
|
||||
return $this->getApplication()->find($command)->run(
|
||||
$this->createInputFromArguments($arguments), new NullOutput
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an input instance from the given arguments.
|
||||
*
|
||||
* @param array $arguments
|
||||
* @return \Symfony\Component\Console\Input\ArrayInput
|
||||
*/
|
||||
protected function createInputFromArguments(array $arguments)
|
||||
{
|
||||
return tap(new ArrayInput($arguments), function ($input) {
|
||||
if ($input->hasParameterOption(['--no-interaction'], true)) {
|
||||
$input->setInteractive(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +244,7 @@ class Command extends SymfonyCommand
|
||||
/**
|
||||
* Get the value of a command argument.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string|null $key
|
||||
* @return string|array
|
||||
*/
|
||||
public function argument($key = null)
|
||||
@@ -227,6 +256,16 @@ class Command extends SymfonyCommand
|
||||
return $this->input->getArgument($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the arguments passed to the command.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function arguments()
|
||||
{
|
||||
return $this->argument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given option is present.
|
||||
*
|
||||
@@ -253,6 +292,16 @@ class Command extends SymfonyCommand
|
||||
return $this->input->getOption($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the options passed to the command.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function options()
|
||||
{
|
||||
return $this->option();
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm a question with the user.
|
||||
*
|
||||
@@ -347,10 +396,11 @@ class Command extends SymfonyCommand
|
||||
*
|
||||
* @param array $headers
|
||||
* @param \Illuminate\Contracts\Support\Arrayable|array $rows
|
||||
* @param string $style
|
||||
* @param string $tableStyle
|
||||
* @param array $columnStyles
|
||||
* @return void
|
||||
*/
|
||||
public function table(array $headers, $rows, $style = 'default')
|
||||
public function table($headers, $rows, $tableStyle = 'default', array $columnStyles = [])
|
||||
{
|
||||
$table = new Table($this->output);
|
||||
|
||||
@@ -358,7 +408,13 @@ class Command extends SymfonyCommand
|
||||
$rows = $rows->toArray();
|
||||
}
|
||||
|
||||
$table->setHeaders($headers)->setRows($rows)->setStyle($style)->render();
|
||||
$table->setHeaders((array) $headers)->setRows($rows)->setStyle($tableStyle);
|
||||
|
||||
foreach ($columnStyles as $columnIndex => $columnStyle) {
|
||||
$table->setColumnStyle($columnIndex, $columnStyle);
|
||||
}
|
||||
|
||||
$table->render();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,6 +498,32 @@ class Command extends SymfonyCommand
|
||||
$this->line($string, 'warning', $verbosity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a string in an alert box.
|
||||
*
|
||||
* @param string $string
|
||||
* @return void
|
||||
*/
|
||||
public function alert($string)
|
||||
{
|
||||
$this->comment(str_repeat('*', strlen($string) + 12));
|
||||
$this->comment('* '.$string.' *');
|
||||
$this->comment(str_repeat('*', strlen($string) + 12));
|
||||
|
||||
$this->output->newLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the verbosity level.
|
||||
*
|
||||
* @param string|int $level
|
||||
* @return void
|
||||
*/
|
||||
protected function setVerbosity($level)
|
||||
{
|
||||
$this->verbosity = $this->parseVerbosity($level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the verbosity level in terms of Symfony's OutputInterface level.
|
||||
*
|
||||
@@ -459,17 +541,6 @@ class Command extends SymfonyCommand
|
||||
return $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the verbosity level.
|
||||
*
|
||||
* @param string|int $level
|
||||
* @return void
|
||||
*/
|
||||
protected function setVerbosity($level)
|
||||
{
|
||||
$this->verbosity = $this->parseVerbosity($level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user