oliverde8 /
comfyBundle
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @author oliverde8<[email protected]> |
||
| 4 | * @category @category oliverde8/ComfyBundle |
||
| 5 | */ |
||
| 6 | |||
| 7 | namespace oliverde8\ComfyBundle\Storage; |
||
| 8 | |||
| 9 | |||
| 10 | use Doctrine\ORM\EntityManagerInterface; |
||
|
0 ignored issues
–
show
|
|||
| 11 | use oliverde8\ComfyBundle\Entity\ConfigValue; |
||
| 12 | |||
| 13 | class DoctrineEntityStorage implements StorageInterface |
||
| 14 | { |
||
| 15 | /** @var EntityManagerInterface */ |
||
| 16 | protected $entityManager; |
||
| 17 | |||
| 18 | /** @var ConfigValue[][] */ |
||
| 19 | protected $entities = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * DoctrineEntityStorage constructor. |
||
| 23 | * @param EntityManagerInterface $entityManager |
||
| 24 | */ |
||
| 25 | public function __construct(EntityManagerInterface $entityManager) |
||
| 26 | { |
||
| 27 | $this->entityManager = $entityManager; |
||
| 28 | } |
||
| 29 | |||
| 30 | |||
| 31 | public function save(string $configPath, string $scope, ?string $value) |
||
| 32 | { |
||
| 33 | // Be sure scope is loaded. |
||
| 34 | $this->load([$scope]); |
||
| 35 | |||
| 36 | if (!isset($this->entities[$scope][$configPath])) { |
||
| 37 | $this->entities[$scope][$configPath] = new ConfigValue(); |
||
| 38 | $this->entities[$scope][$configPath]->setPath($configPath) |
||
| 39 | ->setScope($scope); |
||
| 40 | } |
||
| 41 | $this->entities[$scope][$configPath]->setValue($value); |
||
| 42 | |||
| 43 | if (is_null($value)) { |
||
| 44 | $this->entityManager->remove($this->entities[$scope][$configPath]); |
||
| 45 | } else { |
||
| 46 | $this->entityManager->persist($this->entities[$scope][$configPath]); |
||
| 47 | } |
||
| 48 | |||
| 49 | // TODO improve performance on this. |
||
| 50 | $this->entityManager->flush(); |
||
| 51 | } |
||
| 52 | |||
| 53 | public function load(array $scopes): array |
||
| 54 | { |
||
| 55 | $qb = $this->entityManager->getRepository(ConfigValue::class)->createQueryBuilder("c"); |
||
| 56 | $qb->where($qb->expr()->in('c.scope', $scopes)); |
||
| 57 | |||
| 58 | /** @var ConfigValue[] $result */ |
||
| 59 | $result = $qb->getQuery()->getResult(); |
||
| 60 | |||
| 61 | $groupedConfigValues = []; |
||
| 62 | foreach ($result as $config){ |
||
| 63 | $groupedConfigValues[$config->getScope()][$config->getPath()] = $config->getValue(); |
||
| 64 | $this->entities[$config->getScope()][$config->getPath()] = $config; |
||
| 65 | } |
||
| 66 | |||
| 67 | return $groupedConfigValues; |
||
| 68 | } |
||
| 69 | } |
||
| 70 |
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