function populate() { $tasks_do = new TaskCollection(); $tasks_do->setParams(); $sh = new SearchHandler($tasks_do, false); $sh->setFields(array('id', 'name')); $this->setSearchLimit($sh); $sh->setOrderBy('created', 'ASC'); $sh->addConstraint(new Constraint('progress', '<', 100)); $sh->addConstraint(new Constraint('owner', '=', EGS_USERNAME)); $tasks_do->load($sh); $tasks_do->clickcontroller = 'tasks'; $tasks_do->editclickaction = 'view'; $this->contents = $tasks_do; }
/** * 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); }
/** * Overload get for lazy building of tasks * * @param string $name The property name to access. * @return Shell Object of Task */ public function __get($name) { if (empty($this->{$name}) && in_array($name, $this->taskNames)) { $properties = $this->_taskMap[$name]; $this->{$name} = $this->Tasks->load($properties['class'], $properties['settings']); $this->{$name}->args =& $this->args; $this->{$name}->params =& $this->params; $this->{$name}->initialize(); $this->{$name}->loadTasks(); } return $this->{$name}; }
public function getHourTotals() { $tasks = new TaskCollection(new Task()); $sh = new SearchHandler($tasks, false); $tasks->getTaskHourTotals($sh, $this->id); $tasks->load($sh); $costs = array('total_hours' => 0, 'total_costs' => 0); foreach ($tasks as $task) { $time = explode(':', $task->total_hours); $hours = $time[0] + $time[1] / 60 + $time[2] / 3600; $costs['total_hours'] += $hours; $costs['total_costs'] += $hours * $task->resource_rate; } //echo '<pre>'.print_r($costs, true).'</pre><br>'; return $costs; }
/** * Loads tasks defined in public $tasks * * @return bool */ 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; }