oliverde8 /
comfyBundle
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @author oliverde8<[email protected]> |
||
| 4 | * @category @category oliverde8/ComfyBundle |
||
| 5 | */ |
||
| 6 | |||
| 7 | namespace oliverde8\ComfyBundle\Command; |
||
| 8 | |||
| 9 | use oliverde8\ComfyBundle\Manager\ConfigManagerInterface; |
||
| 10 | use oliverde8\ComfyBundle\Model\ConfigInterface; |
||
| 11 | use oliverde8\ComfyBundle\Resolver\ScopeResolverInterface; |
||
| 12 | use Symfony\Component\Console\Command\Command; |
||
|
0 ignored issues
–
show
|
|||
| 13 | use Symfony\Component\Console\Input\InputArgument; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputArgument was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 14 | use Symfony\Component\Console\Input\InputInterface; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | use Symfony\Component\Console\Input\InputOption; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Input\InputOption was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 16 | use Symfony\Component\Console\Output\OutputInterface; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 17 | use Symfony\Component\Console\Style\SymfonyStyle; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Style\SymfonyStyle was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 18 | |||
| 19 | class GetConfigsCommand extends Command |
||
| 20 | { |
||
| 21 | public const ARG_PATH = "path"; |
||
| 22 | public const OPT_SCOPE = "scope"; |
||
| 23 | |||
| 24 | /** @var ConfigManagerInterface */ |
||
| 25 | protected $configManager; |
||
| 26 | |||
| 27 | public function __construct(ConfigManagerInterface $configManager) |
||
| 28 | { |
||
| 29 | parent::__construct(); |
||
| 30 | $this->configManager = $configManager; |
||
| 31 | } |
||
| 32 | |||
| 33 | |||
| 34 | protected function configure(): void |
||
| 35 | { |
||
| 36 | parent::configure(); |
||
| 37 | $this->setName("comfy:get"); |
||
| 38 | $this->setDescription("Get 'raw' configuration values for a given scope or default scope."); |
||
| 39 | |||
| 40 | $this->addArgument(self::ARG_PATH, InputArgument::REQUIRED); |
||
| 41 | $this->addOption(self::OPT_SCOPE, null, InputOption::VALUE_OPTIONAL); |
||
| 42 | } |
||
| 43 | |||
| 44 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 45 | { |
||
| 46 | $path = $input->getArgument(self::ARG_PATH); |
||
| 47 | $scope = $input->getOption(self::OPT_SCOPE) ?? null; |
||
| 48 | |||
| 49 | $sfs = new SymfonyStyle($input, $output); |
||
| 50 | $configs = $this->configManager->getAllConfigs()->get($path); |
||
| 51 | |||
| 52 | if (empty($configs)) { |
||
| 53 | $sfs->error("No configs found for path '$path'"); |
||
| 54 | return self::SUCCESS; |
||
| 55 | } |
||
| 56 | |||
| 57 | if (!is_array($configs)) { |
||
| 58 | $configs = [$configs]; |
||
| 59 | } |
||
| 60 | |||
| 61 | $lines = []; |
||
| 62 | $this->getLinesRecursively($lines, $configs, $scope); |
||
| 63 | $sfs->table(["code", "name"], $lines); |
||
| 64 | |||
| 65 | return self::SUCCESS; |
||
| 66 | } |
||
| 67 | |||
| 68 | private function getLinesRecursively(&$lines, array $configs, ?string $scope) |
||
| 69 | { |
||
| 70 | foreach ($configs as $config) { |
||
| 71 | if (is_array($config)) { |
||
| 72 | $this->getLinesRecursively($lines, $config, $scope); |
||
| 73 | } else { |
||
| 74 | /** @var ConfigInterface $config */ |
||
| 75 | $lines[] = [$config->getPath(), $config->getRawValue($scope)]; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 | } |
||
| 80 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths