Cronario\AbstractJob::__invoke PHP Method

__invoke() public method

public __invoke ( AbstractJob $parentJob = null ) : ResultException | null
$parentJob AbstractJob
return Cronario\Exception\ResultException | null
    public function __invoke(AbstractJob $parentJob = null)
    {
        if (null !== $parentJob) {
            $this->setParentId($parentJob->getId())->setAuthor($parentJob->getAuthor());
        }
        $this->save();
        try {
            if ($this->isSync()) {
                $worker = AbstractWorker::factory($this->getWorkerClass());
                $worker($this);
            } else {
                $this->setResult(new ResultException(ResultException::R_QUEUED));
                $this->putIntoQueue();
                $this->save();
            }
        } catch (\Exception $ex) {
            $this->setResult($ex);
            $this->save();
        }
        return $this->getResult();
    }