|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String; |
|
4
|
|
|
|
|
5
|
|
|
// phpcs:disable Generic.Files.LineLength.TooLong |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; |
|
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\JsonDataFieldInterface; |
|
9
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Validation\Constraints\DomainName; |
|
|
|
|
|
|
10
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Validation\Constraints\FieldConstraints\JsonData; |
|
11
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper; |
|
12
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData; |
|
13
|
|
|
|
|
14
|
|
|
// phpcs:enable |
|
15
|
|
|
trait JsonDataFieldTrait |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var string|null |
|
20
|
|
|
*/ |
|
21
|
|
|
private $jsonData; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @SuppressWarnings(PHPMD.StaticAccess) |
|
25
|
|
|
* @param ClassMetadataBuilder $builder |
|
26
|
|
|
*/ |
|
27
|
6 |
|
public static function metaForJson(ClassMetadataBuilder $builder): void |
|
28
|
|
|
{ |
|
29
|
6 |
|
MappingHelper::setSimpleJsonFields( |
|
30
|
6 |
|
[JsonDataFieldInterface::PROP_JSON_DATA], |
|
31
|
6 |
|
$builder, |
|
32
|
6 |
|
JsonDataFieldInterface::DEFAULT_JSON_DATA, |
|
33
|
6 |
|
false |
|
|
|
|
|
|
34
|
|
|
); |
|
35
|
6 |
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Use a custom validator to call filter_var to validate that the domain name is valid |
|
39
|
|
|
* |
|
40
|
|
|
* @param ValidatorClassMetaData $metadata |
|
41
|
|
|
*/ |
|
42
|
6 |
|
protected static function validatorMetaForPropertyJson(ValidatorClassMetaData $metadata): void |
|
43
|
|
|
{ |
|
44
|
6 |
|
$metadata->addPropertyConstraint( |
|
45
|
6 |
|
JsonDataFieldInterface::PROP_JSON_DATA, |
|
46
|
6 |
|
new JsonData() |
|
47
|
|
|
); |
|
48
|
6 |
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return string|null |
|
52
|
|
|
*/ |
|
53
|
6 |
|
public function getJsonData(): ?string |
|
54
|
|
|
{ |
|
55
|
6 |
|
if (null === $this->jsonData) { |
|
56
|
6 |
|
return JsonDataFieldInterface::DEFAULT_JSON_DATA; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
6 |
|
return $this->jsonData; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param string|null $json |
|
64
|
|
|
* |
|
65
|
|
|
* @return self |
|
66
|
|
|
*/ |
|
67
|
6 |
|
private function setJsonData(?string $json): self |
|
68
|
|
|
{ |
|
69
|
6 |
|
$this->updatePropertyValue( |
|
|
|
|
|
|
70
|
6 |
|
JsonDataFieldInterface::PROP_JSON_DATA, |
|
71
|
6 |
|
$json |
|
72
|
|
|
); |
|
73
|
|
|
|
|
74
|
6 |
|
return $this; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
6 |
|
private function initJsonData() |
|
78
|
|
|
{ |
|
79
|
6 |
|
$this->jsonData = JsonDataFieldInterface::DEFAULT_JSON_DATA; |
|
80
|
6 |
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
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