/** * @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]; }
/** * @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); }