1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ControleOnline\Repository\ExtraDataRepository; |
8
|
|
|
use ControleOnline\Listener\LogListener; |
9
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
15
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
16
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
17
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
|
|
|
18
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
|
|
|
19
|
|
|
use Doctrine\ORM\Mapping\EntityListeners; |
|
|
|
|
20
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
|
|
|
21
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
|
|
|
22
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
|
|
|
23
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
|
|
|
24
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
|
|
|
25
|
|
|
|
26
|
|
|
#[ApiResource( |
27
|
|
|
operations: [ |
28
|
|
|
new Get(uriTemplate: '/extra_data/{id}', security: 'is_granted(\'ROLE_CLIENT\')'), |
29
|
|
|
new GetCollection(uriTemplate: '/extra_data', security: 'is_granted(\'ROLE_CLIENT\')'), |
30
|
|
|
new Put( |
31
|
|
|
uriTemplate: '/extra_data/{id}', |
32
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
33
|
|
|
validationContext: ['groups' => ['extra_data:write']], |
34
|
|
|
denormalizationContext: ['groups' => ['extra_data:write']] |
35
|
|
|
), |
36
|
|
|
new Delete(uriTemplate: '/extra_data/{id}', security: 'is_granted(\'ROLE_CLIENT\')'), |
37
|
|
|
new Post(uriTemplate: '/extra_data', securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
38
|
|
|
], |
39
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
40
|
|
|
normalizationContext: ['groups' => ['extra_data:read']], |
41
|
|
|
denormalizationContext: ['groups' => ['extra_data:write']] |
42
|
|
|
)] |
43
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: [ |
44
|
|
|
'id' => 'exact', |
45
|
|
|
'extra_fields' => 'exact', |
46
|
|
|
'entity_id' => 'exact', |
47
|
|
|
'entity_name' => 'exact', |
48
|
|
|
// 'people' filter seems out of place as there's no 'people' property, |
49
|
|
|
// unless it relates to ExtraFields or another implicit context. |
50
|
|
|
// Keeping it based on the original code, but review if it's functional. |
51
|
|
|
'people' => 'exact' |
52
|
|
|
])] |
53
|
|
|
#[Table(name: 'extra_data')] |
54
|
|
|
#[EntityListeners([LogListener::class])] |
55
|
|
|
#[Entity(repositoryClass: ExtraDataRepository::class)] |
56
|
|
|
class ExtraData |
57
|
|
|
{ |
58
|
|
|
#[Groups(['extrafields:read', 'extra_data:read'])] |
59
|
|
|
#[Column(name: 'id', type: 'integer', nullable: false)] |
60
|
|
|
#[Id] |
61
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
62
|
|
|
private int $id = 0; |
63
|
|
|
|
64
|
|
|
#[Groups(['extra_data:read'])] |
65
|
|
|
#[JoinColumn(name: 'extra_fields_id', referencedColumnName: 'id', nullable: true)] // Assuming nullable based on lack of 'nullable: false' |
66
|
|
|
#[ManyToOne(targetEntity: ExtraFields::class)] |
67
|
|
|
private ?ExtraFields $extra_fields = null; |
68
|
|
|
|
69
|
|
|
#[Groups(['extra_data:read'])] |
70
|
|
|
#[Column(name: 'entity_id', type: 'string', nullable: false)] |
71
|
|
|
private string $entity_id; |
72
|
|
|
|
73
|
|
|
#[Groups(['extra_data:read'])] |
74
|
|
|
#[Column(name: 'entity_name', type: 'string', nullable: false)] |
75
|
|
|
private string $entity_name; |
76
|
|
|
|
77
|
|
|
#[Groups(['extra_data:read'])] |
78
|
|
|
#[Column(name: 'data_value', type: 'string', nullable: false)] |
79
|
|
|
private string $value; |
80
|
|
|
|
81
|
|
|
public function __construct() |
82
|
|
|
{ |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getId(): int |
86
|
|
|
{ |
87
|
|
|
return $this->id; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function setValue(string $value): self |
91
|
|
|
{ |
92
|
|
|
$this->value = $value; |
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function getValue(): string |
97
|
|
|
{ |
98
|
|
|
return $this->value; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function getEntityId(): string |
102
|
|
|
{ |
103
|
|
|
return $this->entity_id; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function setEntityId(int | string $entity_id): self |
107
|
|
|
{ |
108
|
|
|
$this->entity_id = $entity_id; |
109
|
|
|
return $this; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function getEntityName(): string |
113
|
|
|
{ |
114
|
|
|
return $this->entity_name; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function setEntityName(string $entity_name): self |
118
|
|
|
{ |
119
|
|
|
$this->entity_name = $entity_name; |
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function getExtraFields(): ?ExtraFields |
124
|
|
|
{ |
125
|
|
|
return $this->extra_fields; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function setExtraFields(?ExtraFields $extra_fields): self |
129
|
|
|
{ |
130
|
|
|
$this->extra_fields = $extra_fields; |
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
} |
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