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();
}