1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
14
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
15
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
16
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
17
|
|
|
use ControleOnline\Entity\Contract; |
18
|
|
|
use ControleOnline\Repository\ContractPeopleRepository; |
19
|
|
|
use ControleOnline\Listener\LogListener; |
|
|
|
|
20
|
|
|
|
21
|
|
|
#[ORM\Table(name: 'contract_people')] |
22
|
|
|
#[ORM\EntityListeners([LogListener::class])] |
23
|
|
|
#[ORM\Entity(repositoryClass: ContractPeopleRepository::class)] |
24
|
|
|
#[ApiResource( |
25
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
26
|
|
|
normalizationContext: ['groups' => ['contract_people:read']], |
27
|
|
|
denormalizationContext: ['groups' => ['contract_people:write']], |
28
|
|
|
security: "is_granted('ROLE_CLIENT')", |
29
|
|
|
operations: [ |
30
|
|
|
new GetCollection(security: "is_granted('ROLE_CLIENT')"), |
31
|
|
|
new Get(security: "is_granted('ROLE_CLIENT')"), |
32
|
|
|
new Post( |
33
|
|
|
security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')" |
34
|
|
|
), |
35
|
|
|
new Put( |
36
|
|
|
security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')", |
37
|
|
|
validationContext: ['groups' => ['contract_people:write']], |
38
|
|
|
denormalizationContext: ['groups' => ['contract_people:write']] |
39
|
|
|
), |
40
|
|
|
new Delete(security: "is_granted('ROLE_CLIENT')") |
41
|
|
|
] |
42
|
|
|
)] |
43
|
|
|
#[ApiFilter(SearchFilter::class, properties: [ |
44
|
|
|
'id' => 'exact', |
45
|
|
|
'people.id' => 'exact', |
46
|
|
|
'peopleType' => 'exact', |
47
|
|
|
'contract' => 'exact' |
48
|
|
|
])] |
49
|
|
|
class ContractPeople |
50
|
|
|
{ |
51
|
|
|
#[ORM\Column(type: 'integer', nullable: false)] |
52
|
|
|
#[ORM\Id] |
53
|
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')] |
54
|
|
|
#[Groups(['contract_people:read', 'contract:read'])] |
55
|
|
|
private $id; |
56
|
|
|
|
57
|
|
|
#[ORM\ManyToOne(targetEntity: People::class)] |
58
|
|
|
#[ORM\JoinColumn(name: 'people_id', referencedColumnName: 'id', nullable: false)] |
59
|
|
|
#[Groups(['contract_people:read', 'contract:read', 'contract_people:write'])] |
60
|
|
|
private $people; |
61
|
|
|
|
62
|
|
|
#[ORM\Column(name: 'people_type', type: 'string')] |
63
|
|
|
#[Groups(['contract_people:read', 'contract:read', 'contract_people:write'])] |
64
|
|
|
private $peopleType; |
65
|
|
|
|
66
|
|
|
#[ORM\ManyToOne(targetEntity: Contract::class, inversedBy: 'peoples')] |
67
|
|
|
#[ORM\JoinColumn(name: 'contract_id', referencedColumnName: 'id')] |
68
|
|
|
#[Groups(['contract_people:read', 'contract_people:write'])] |
69
|
|
|
private $contract; |
70
|
|
|
|
71
|
|
|
#[ORM\Column(name: 'contract_percentage', type: 'float', nullable: true)] |
72
|
|
|
#[Groups(['contract_people:read', 'contract:read', 'contract_people:write'])] |
73
|
|
|
private $contractPercentage; |
74
|
|
|
|
75
|
|
|
public function getId() |
76
|
|
|
{ |
77
|
|
|
return $this->id; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function setId($id): self |
81
|
|
|
{ |
82
|
|
|
$this->id = $id; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getContract() |
87
|
|
|
{ |
88
|
|
|
return $this->contract; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function setContract($contract): self |
92
|
|
|
{ |
93
|
|
|
$this->contract = $contract; |
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getPeople() |
98
|
|
|
{ |
99
|
|
|
return $this->people; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setPeople($people): self |
103
|
|
|
{ |
104
|
|
|
$this->people = $people; |
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getPeopleType() |
109
|
|
|
{ |
110
|
|
|
return $this->peopleType; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function setPeopleType($peopleType): self |
114
|
|
|
{ |
115
|
|
|
$this->peopleType = $peopleType; |
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getContractPercentage() |
120
|
|
|
{ |
121
|
|
|
return $this->contractPercentage; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function setContractPercentage($contractPercentage): self |
125
|
|
|
{ |
126
|
|
|
$this->contractPercentage = $contractPercentage; |
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|
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