Ejemplo n.º 1
0
 /**
  * Return a list of subcommands for a given command
  *
  * @param string $commandName The command you want subcommands from.
  *
  * @return array
  */
 public function subCommands($commandName)
 {
     $Shell = $this->getShell($commandName);
     if (!$Shell) {
         return array();
     }
     $taskMap = TaskCollection::normalizeObjectArray((array) $Shell->tasks);
     $return = array_keys($taskMap);
     $return = array_map('Inflector::underscore', $return);
     $ShellReflection = new ReflectionClass('AppShell');
     $shellMethods = $ShellReflection->getMethods(ReflectionMethod::IS_PUBLIC);
     $shellMethodNames = array('main', 'help');
     foreach ($shellMethods as $method) {
         $shellMethodNames[] = $method->getName();
     }
     $Reflection = new ReflectionClass($Shell);
     $methods = $Reflection->getMethods(ReflectionMethod::IS_PUBLIC);
     $methodNames = array();
     foreach ($methods as $method) {
         $methodNames[] = $method->getName();
     }
     $return += array_diff($methodNames, $shellMethodNames);
     sort($return);
     return $return;
 }
 /**
  * __construct
  *
  * Ensure that required tasks are loaded, account for simple declaration
  * or declaring with options
  *
  * @param mixed $stdout
  * @param mixed $stderr
  * @param mixed $stdin
  */
 public function __construct($stdout = null, $stderr = null, $stdin = null)
 {
     $requiredTasks = array('Common.ProccessManagement', 'Common.GearmanWorker');
     $existingTasks = TaskCollection::normalizeObjectArray($this->tasks);
     foreach ($requiredTasks as $task) {
         list(, $name) = pluginSplit($task);
         if (!isset($existingTasks[$name])) {
             $this->tasks[] = $task;
         }
     }
     parent::__construct($stdout, $stderr, $stdin);
 }
Ejemplo n.º 3
0
 /**
  * Loads tasks defined in public $tasks
  *
  * @return boolean
  */
 public function loadTasks()
 {
     if ($this->tasks === true || empty($this->tasks) || empty($this->Tasks)) {
         return true;
     }
     $this->_taskMap = TaskCollection::normalizeObjectArray((array) $this->tasks);
     $this->taskNames = array_merge($this->taskNames, array_keys($this->_taskMap));
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Loads tasks defined in public $tasks
  *
  * @return boolean
  */
 public function loadTasks()
 {
     if ($this->tasks === true || empty($this->tasks) || empty($this->Tasks)) {
         return true;
     }
     $this->_taskMap = TaskCollection::normalizeObjectArray((array) $this->tasks);
     foreach ($this->_taskMap as $task => $properties) {
         $this->taskNames[] = $task;
     }
     return true;
 }