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

namespace IlluminateFoundationConsole;

use 
Closure;
use 
IlluminateConsoleCommand;
use 
ReflectionFunction;
use 
SymfonyComponentConsoleInputInputInterface;
use 
SymfonyComponentConsoleOutputOutputInterface;

class 
ClosureCommand extends Command
{
    
/**
     * The command callback.
     *
     * @var Closure
     */
    
protected $callback;

    
/**
     * Create a new command instance.
     *
     * @param  string  $signature
     * @param  Closure  $callback
     * @return void
     */
    
public function __construct($signatureClosure $callback)
    {
        
$this->callback $callback;
        
$this->signature $signature;

        
parent::__construct();
    }

    
/**
     * Execute the console command.
     *
     * @param  SymfonyComponentConsoleInputInputInterface  $input
     * @param  SymfonyComponentConsoleOutputOutputInterface  $output
     * @return int
     */
    
protected function execute(InputInterface $inputOutputInterface $output)
    {
        
$inputs array_merge($input->getArguments(), $input->getOptions());

        
$parameters = [];

        foreach ((new 
ReflectionFunction($this->callback))->getParameters() as $parameter) {
            if (isset(
$inputs[$parameter->getName()])) {
                
$parameters[$parameter->getName()] = $inputs[$parameter->getName()];
            }
        }

        return (int) 
$this->laravel->call(
            
$this->callback->bindTo($this$this), $parameters
        
);
    }

    
/**
     * Set the description for the command.
     *
     * @param  string  $description
     * @return $this
     */
    
public function purpose($description)
    {
        return 
$this->describe($description);
    }

    
/**
     * Set the description for the command.
     *
     * @param  string  $description
     * @return $this
     */
    
public function describe($description)
    {
        
$this->setDescription($description);

        return 
$this;
    }
}
Онлайн: 1
Реклама