/** * Handle onBefore, onAfter and name * * @param mixed $offset The name of the variable * @param mixed $value The value * * @return void */ public function offsetSet($offset, $value) { if ($offset === 'onBefore' || $offset == 'onAfter') { $type = lcfirst(substr($offset, 2)); $name = $this->offsetGet('name'); $factory = $this->console->getFactory(); foreach ((array) $this->expand($value) as $subTask) { $subTask = $factory->createTask($this->expand($subTask), $this, [$type => $name]); $this->job->addTask($subTask); } } if ($offset === 'name' && parent::offsetGet('name')) { throw new Exception('name may not be set doubly (try putting it at top of the task/job/workflow configuration'); } parent::offsetSet($offset, $value); }
/** * Create and return the job * * @return Job */ public function getJob() { if (!$this->job) { $this->job = $this->console->getFactory()->createJob($this->getName()); } return $this->job; }