Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php
Строк: 207
<?php

namespace IlluminateConsoleConcerns;

use 
SymfonyComponentConsoleInputArrayInput;
use 
SymfonyComponentConsoleOutputNullOutput;
use 
SymfonyComponentConsoleOutputOutputInterface;

trait 
CallsCommands
{
    
/**
     * Resolve the console command instance for the given command.
     *
     * @param  SymfonyComponentConsoleCommandCommand|string  $command
     * @return SymfonyComponentConsoleCommandCommand
     */
    
abstract protected function resolveCommand($command);

    
/**
     * Call another console command.
     *
     * @param  SymfonyComponentConsoleCommandCommand|string  $command
     * @param  array  $arguments
     * @return int
     */
    
public function call($command, array $arguments = [])
    {
        return 
$this->runCommand($command$arguments$this->output);
    }

    
/**
     * Call another console command without output.
     *
     * @param  SymfonyComponentConsoleCommandCommand|string  $command
     * @param  array  $arguments
     * @return int
     */
    
public function callSilent($command, array $arguments = [])
    {
        return 
$this->runCommand($command$arguments, new NullOutput);
    }

    
/**
     * Call another console command without output.
     *
     * @param  SymfonyComponentConsoleCommandCommand|string  $command
     * @param  array  $arguments
     * @return int
     */
    
public function callSilently($command, array $arguments = [])
    {
        return 
$this->callSilent($command$arguments);
    }

    
/**
     * Run the given the console command.
     *
     * @param  SymfonyComponentConsoleCommandCommand|string  $command
     * @param  array  $arguments
     * @param  SymfonyComponentConsoleOutputOutputInterface  $output
     * @return int
     */
    
protected function runCommand($command, array $argumentsOutputInterface $output)
    {
        
$arguments['command'] = $command;

        return 
$this->resolveCommand($command)->run(
            
$this->createInputFromArguments($arguments), $output
        
);
    }

    
/**
     * Create an input instance from the given arguments.
     *
     * @param  array  $arguments
     * @return SymfonyComponentConsoleInputArrayInput
     */
    
protected function createInputFromArguments(array $arguments)
    {
        return 
tap(new ArrayInput(array_merge($this->context(), $arguments)), function ($input) {
            if (
$input->getParameterOption('--no-interaction')) {
                
$input->setInteractive(false);
            }
        });
    }

    
/**
     * Get all of the context passed to the command.
     *
     * @return array
     */
    
protected function context()
    {
        return 
collect($this->option())->only([
            
'ansi',
            
'no-ansi',
            
'no-interaction',
            
'quiet',
            
'verbose',
        ])->
filter()->mapWithKeys(function ($value$key) {
            return [
"--{$key}=> $value];
        })->
all();
    }
}
Онлайн: 1
Реклама