1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ControleOnline\Repository\LanguageRepository; |
8
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
9
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
10
|
|
|
use ControleOnline\Listener\LogListener; |
11
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
15
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
16
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
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\OneToMany; |
|
|
|
|
23
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
|
|
|
24
|
|
|
use Doctrine\ORM\Mapping\UniqueConstraint; |
|
|
|
|
25
|
|
|
|
26
|
|
|
#[ApiResource( |
27
|
|
|
operations: [ |
28
|
|
|
new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'), |
29
|
|
|
new Put( |
30
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
31
|
|
|
denormalizationContext: ['groups' => ['language:read']] // Note: Usually Put uses a :write group, check if :read is intended |
32
|
|
|
), |
33
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
34
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), // Consider adding validationContext/denormalizationContext if needed |
35
|
|
|
new GetCollection( |
36
|
|
|
security: 'is_granted(\'PUBLIC_ACCESS\')', |
37
|
|
|
) |
38
|
|
|
], |
39
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
40
|
|
|
normalizationContext: ['groups' => ['language:read']], |
41
|
|
|
denormalizationContext: ['groups' => ['language:write']] |
42
|
|
|
)] |
43
|
|
|
#[Table(name: 'language')] |
44
|
|
|
#[UniqueConstraint(name: 'language', columns: ['language'])] |
45
|
|
|
#[Entity(repositoryClass: LanguageRepository::class)] |
46
|
|
|
#[EntityListeners([LogListener::class])] |
47
|
|
|
class Language |
48
|
|
|
{ |
49
|
|
|
#[Groups(['translate:read', 'language:read'])] |
50
|
|
|
#[Column(type: 'integer', nullable: false)] |
51
|
|
|
#[Id] |
52
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
53
|
|
|
private int $id = 0; |
54
|
|
|
|
55
|
|
|
#[Groups(['translate:read', 'language:read'])] |
56
|
|
|
#[Column(type: 'string', length: 10, nullable: false)] |
57
|
|
|
private string $language; |
58
|
|
|
|
59
|
|
|
#[Groups(['translate:read', 'language:read'])] |
60
|
|
|
#[Column(type: 'boolean', nullable: false)] |
61
|
|
|
private bool $locked; |
62
|
|
|
|
63
|
|
|
#[OneToMany(targetEntity: People::class, mappedBy: 'language')] |
64
|
|
|
private Collection $people; |
65
|
|
|
|
66
|
|
|
public function __construct() |
67
|
|
|
{ |
68
|
|
|
$this->people = new ArrayCollection(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function getId(): int |
72
|
|
|
{ |
73
|
|
|
return $this->id; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function addPeople(People $people): self |
|
|
|
|
77
|
|
|
{ |
78
|
|
|
if (!$this->people->contains($people)) { |
79
|
|
|
$this->people[] = $people; |
80
|
|
|
// If People entity has a setLanguage method to maintain the bidirectional relationship: |
81
|
|
|
// $people->setLanguage($this); |
82
|
|
|
} |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function removePeople(People $people): self |
87
|
|
|
{ |
88
|
|
|
if ($this->people->removeElement($people)) { |
89
|
|
|
// If People entity has a setLanguage method and it's the owning side or needs nulling: |
90
|
|
|
// if ($people->getLanguage() === $this) { |
91
|
|
|
// $people->setLanguage(null); |
92
|
|
|
// } |
93
|
|
|
} |
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getPeople(): Collection |
98
|
|
|
{ |
99
|
|
|
return $this->people; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setLanguage(string $language): self |
103
|
|
|
{ |
104
|
|
|
$this->language = $language; |
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getLanguage(): string |
109
|
|
|
{ |
110
|
|
|
return $this->language; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function setLocked(bool $locked): self |
114
|
|
|
{ |
115
|
|
|
$this->locked = $locked; |
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getLocked(): bool |
120
|
|
|
{ |
121
|
|
|
return $this->locked; |
122
|
|
|
} |
123
|
|
|
} |
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