|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControleOnline\Service; |
|
4
|
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Config; |
|
6
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
|
|
7
|
|
|
use ControleOnline\Entity\PeopleDomain; |
|
|
|
|
|
|
8
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
|
|
|
|
|
9
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
|
|
|
|
10
|
|
|
use InvalidArgumentException; |
|
11
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
|
|
12
|
|
|
use phpDocumentor\Reflection\PseudoTypes\Numeric_; |
|
|
|
|
|
|
13
|
|
|
use phpDocumentor\Reflection\Types\Integer; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class ConfigService |
|
16
|
|
|
{ |
|
17
|
|
|
private $request; |
|
18
|
|
|
public function __construct( |
|
19
|
|
|
private EntityManagerInterface $manager, |
|
20
|
|
|
private RequestStack $requestStack |
|
21
|
|
|
) { |
|
22
|
|
|
$this->request = $requestStack->getCurrentRequest(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function getConfig(People $people, $key, $json = false) |
|
26
|
|
|
{ |
|
27
|
|
|
$config = $this->discoveryConfig($people, $key, false); |
|
28
|
|
|
$value = $config ? $config->getConfigValue() : null; |
|
29
|
|
|
return $json ? json_decode($value) : $value; |
|
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
private function discoveryConfig(People $people, $key, $create = true): ?Config |
|
33
|
|
|
{ |
|
34
|
|
|
$config = $this->manager->getRepository(Config::class)->findOneBy([ |
|
35
|
|
|
'people' => $people, |
|
36
|
|
|
'configKey' => $key |
|
37
|
|
|
]); |
|
38
|
|
|
if ($config) |
|
39
|
|
|
return $config; |
|
40
|
|
|
if ($create) { |
|
41
|
|
|
$config = new Config(); |
|
42
|
|
|
$config->setConfigKey($key); |
|
43
|
|
|
$config->setPeople($people); |
|
44
|
|
|
} |
|
45
|
|
|
return null; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function addConfig(People $people, string $key, array $values) |
|
49
|
|
|
{ |
|
50
|
|
|
$config = $this->discoveryConfig($people, $key); |
|
51
|
|
|
$newValue = json_decode($config->getConfigValue()) || []; |
|
52
|
|
|
if (!is_array($newValue)) |
|
|
|
|
|
|
53
|
|
|
$newValue = [$newValue]; |
|
54
|
|
|
|
|
55
|
|
|
if (is_array($values)) |
|
|
|
|
|
|
56
|
|
|
foreach ($values as $key => $value) |
|
57
|
|
|
$newValue[$key] = $value; |
|
58
|
|
|
else |
|
59
|
|
|
$newValue[] = $values; |
|
60
|
|
|
|
|
61
|
|
|
$config->setConfigValue(json_encode($newValue)); |
|
62
|
|
|
$this->manager->persist($config); |
|
63
|
|
|
$this->manager->flush(); |
|
64
|
|
|
return $config; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
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