public function execute(CommandInterface $command) { if ($command->getName() !== CommandInterface::COMMAND_CREATE) { throw new \InvalidArgumentException("Command type \" {$command->getName()} not supported"); } return $this->create($command->getClass(), $command->getParams()); }
/** * @param CommandInterface $command * @return WorkerInterface[] */ public function getCommandWorkers(CommandInterface $command) { $class = (string) $command->getClass(); $action = $command->getName(); do { if (false === $class) { $class = ""; } $path = [$action, $class]; if (ArrayUtils::issetByPath($this->actionMap, $path)) { $workers = ArrayUtils::get($this->actionMap, $path); $workers = ArrayUtils::sortByKey($workers); //may be cache like: $this->actionMap = ArrayUtils::set($this->actionMap, $path, $workers); foreach ($workers as $worker) { (yield $this->getWorker($worker["name"])); } } if ("" !== $class) { $class = get_parent_class($class); } } while ("" !== $class); }