ConsoleKit\Command::execute PHP Method

execute() public method

Commands must be defined as methods named after the command, prefixed with execute (eg. create -> executeCreate)
public execute ( array $args, array $options = [] )
$args array
$options array
    public function execute(array $args, array $options = array())
    {
        if (!count($args)) {
            throw new ConsoleException("Missing subcommand name");
        }
        $command = ucfirst(Utils::camelize(array_shift($args)));
        $methodName = "execute{$command}";
        if (!method_exists($this, $methodName)) {
            throw new ConsoleException("Command '{$command}' does not exist");
        }
        $method = new ReflectionMethod($this, $methodName);
        $params = Utils::computeFuncParams($method, $args, $options);
        return $method->invokeArgs($this, $params);
    }

Usage Example

Esempio n. 1
0
 public function execute(array $args, array $options = array())
 {
     if (isset($options['verbose'])) {
         $this->verbose = isset($options['verbose']);
     }
     return parent::execute($args, $options);
 }