示例#1
0
 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());
 }
示例#2
0
 /**
  * @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);
 }