dispatcher = $dispatcher; $this->logger = $logger; $this->translator = $translator; } /** * @param string $fqn * @return JobInterface */ public function create($fqn) { if (!class_exists($fqn)) { $tryFqn = __NAMESPACE__ . '\\' . $fqn . 'Job'; if (!class_exists($tryFqn)) { throw new InvalidArgumentException(sprintf('Job `%s` not found.', $fqn)); } $fqn = $tryFqn; } if (!in_array('Alchemy\Phrasea\TaskManager\Job\JobInterface', class_implements($fqn))) { throw new InvalidArgumentException(sprintf('Class `%s` does not implement JobInterface.', $fqn)); } return new $fqn($this->translator, $this->dispatcher, $this->logger); } }