Ejemplo n.º 1
0
 /**
  * @param null $path
  * @param null $default
  * @return $this|null
  */
 public function get($path = null, $default = null)
 {
     if (is_null($path)) {
         return $this;
     }
     $pathKey = implode('|', (array) $path);
     if (!isset($this->childConfig[$pathKey])) {
         if (!ArrayUtils::issetByPath($this->configRaw, $path)) {
             return is_array($default) ? new Config([]) : $default;
         }
         $needConfig = ArrayUtils::getByPath($this->configRaw, $path, $default);
         if (is_array($needConfig)) {
             $this->childConfig[$pathKey] = new Config($needConfig);
         } else {
             $this->childConfig[$pathKey] = $needConfig;
         }
     }
     return $this->childConfig[$pathKey];
 }
Ejemplo n.º 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);
 }