1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace oliverde8\ComfyBundle\Model; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
8
|
|
|
use oliverde8\ComfyBundle\Manager\ConfigManagerInterface; |
9
|
|
|
use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class EntityConfig extends TextConfig |
12
|
|
|
{ |
13
|
|
|
private EntityManagerInterface $entityManager; |
14
|
|
|
|
15
|
|
|
protected string $entity; |
16
|
|
|
|
17
|
|
|
protected string $choiceLabel; |
18
|
|
|
|
19
|
|
|
public function __construct( |
20
|
|
|
ConfigManagerInterface $configManager, |
21
|
|
|
ValidatorInterface $validator, |
22
|
|
|
EntityManagerInterface $entityManager, |
23
|
|
|
string $path, |
24
|
|
|
string $name, |
25
|
|
|
string $description = "", |
26
|
|
|
int $scope = PHP_INT_MAX, |
27
|
|
|
?string $defaultValue = null, |
28
|
|
|
bool $isHidden = false, |
29
|
|
|
string $entity = "", |
30
|
|
|
string $choiceLabel = "id" |
31
|
|
|
) { |
32
|
|
|
parent::__construct($configManager, $validator, $path, $name, $description, $scope, $defaultValue, $isHidden); |
33
|
|
|
|
34
|
|
|
$this->entityManager = $entityManager; |
35
|
|
|
$this->entity = $entity; |
36
|
|
|
$this->choiceLabel = $choiceLabel; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Serialize value to save it in Database. |
41
|
|
|
* |
42
|
|
|
* @param $value |
43
|
|
|
* |
44
|
|
|
* @return string|null |
45
|
|
|
*/ |
46
|
|
|
protected function serialize($value): ?string |
47
|
|
|
{ |
48
|
|
|
if (is_object($value)) { |
49
|
|
|
return $value->getId(); |
50
|
|
|
} else { |
51
|
|
|
return $value; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
public function getEntity(): string |
59
|
|
|
{ |
60
|
|
|
return $this->entity; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getChoiceLabel(): string |
67
|
|
|
{ |
68
|
|
|
return $this->choiceLabel; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Deserialize value read from database. |
73
|
|
|
* |
74
|
|
|
* @param string|null $value |
75
|
|
|
* |
76
|
|
|
* @return mixed|null |
77
|
|
|
*/ |
78
|
|
|
protected function deserialize(?string $value) |
79
|
|
|
{ |
80
|
|
|
if ($value) { |
81
|
|
|
return $this->entityManager->getRepository($this->entity)->find($value); |
82
|
|
|
} else { |
83
|
|
|
return null; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
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