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 ![]() |
|||
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 ![]() |
|||
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 ![]() |
|||
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 ![]() |
|||
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 ![]() |
|||
18 | use Symfony\Component\Validator\ConstraintViolationInterface; |
||
0 ignored issues
–
show
The type
Symfony\Component\Valida...raintViolationInterface 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 ![]() |
|||
19 | |||
20 | class SetConfigsCommand extends Command |
||
21 | { |
||
22 | public const ARG_PATH = "path"; |
||
23 | public const ARG_VALUE = "value"; |
||
24 | public const OPT_SCOPE = "scope"; |
||
25 | |||
26 | /** @var ConfigManagerInterface */ |
||
27 | protected $configManager; |
||
28 | |||
29 | public function __construct(ConfigManagerInterface $configManager) |
||
30 | { |
||
31 | parent::__construct(); |
||
32 | $this->configManager = $configManager; |
||
33 | } |
||
34 | |||
35 | |||
36 | protected function configure(): void |
||
37 | { |
||
38 | parent::configure(); |
||
39 | $this->setName("comfy:set"); |
||
40 | $this->setDescription("Set 'raw' configuration values for a given scope or default scope."); |
||
41 | |||
42 | $this->addArgument(self::ARG_PATH, InputArgument::REQUIRED); |
||
43 | $this->addArgument(self::ARG_VALUE); |
||
44 | $this->addOption(self::OPT_SCOPE, null, InputOption::VALUE_OPTIONAL); |
||
45 | } |
||
46 | |||
47 | protected function execute(InputInterface $input, OutputInterface $output) |
||
48 | { |
||
49 | $path = $input->getArgument(self::ARG_PATH); |
||
50 | $value = $input->getArgument(self::ARG_VALUE); |
||
51 | $scope = $input->getOption(self::OPT_SCOPE) ?? null; |
||
52 | |||
53 | $sfs = new SymfonyStyle($input, $output); |
||
54 | /** @var ConfigInterface $config */ |
||
55 | $config = $this->configManager->getAllConfigs()->get($path); |
||
56 | |||
57 | if (empty($config)) { |
||
58 | $sfs->error("No config found for path '$path'"); |
||
59 | return self::SUCCESS; |
||
60 | } |
||
61 | |||
62 | $validations = $config->validate($value, $scope); |
||
63 | if ($validations->count() > 0) { |
||
64 | foreach ($validations as $violation) { |
||
65 | /** @var $violation ConstraintViolationInterface */ |
||
66 | $sfs->warning($violation->getMessage()); |
||
67 | } |
||
68 | return self::FAILURE; |
||
69 | } |
||
70 | |||
71 | $config->set($value, $scope); |
||
72 | $sfs->success("Successfully saved new config value."); |
||
73 | |||
74 | return self::SUCCESS; |
||
75 | } |
||
76 | |||
77 | private function getLinesRecursively(&$lines, array $configs, ?string $scope) |
||
78 | { |
||
79 | foreach ($configs as $config) { |
||
80 | if (is_array($config)) { |
||
81 | $this->getLinesRecursively($lines, $config, $scope); |
||
82 | } else { |
||
83 | /** @var ConfigInterface $config */ |
||
84 | $lines[] = [$config->getPath(), $config->getRawValue($scope)]; |
||
85 | } |
||
86 | } |
||
87 | } |
||
88 | } |
||
89 |
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