1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ControleOnline\Repository\DistrictRepository; |
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\Get; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
14
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
|
|
|
15
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
|
|
|
16
|
|
|
use Doctrine\ORM\Mapping\EntityListeners; |
|
|
|
|
17
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
|
|
|
18
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
|
|
|
19
|
|
|
use Doctrine\ORM\Mapping\Index; |
|
|
|
|
20
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
|
|
|
21
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
|
|
|
22
|
|
|
use Doctrine\ORM\Mapping\OneToMany; |
|
|
|
|
23
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
|
|
|
24
|
|
|
|
25
|
|
|
#[ApiResource( |
26
|
|
|
operations: [ |
27
|
|
|
new Get(security: 'is_granted(\'ROLE_CLIENT\')'), |
28
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')') |
29
|
|
|
], |
30
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
31
|
|
|
normalizationContext: ['groups' => ['district:read']], |
32
|
|
|
denormalizationContext: ['groups' => ['district:write']] |
33
|
|
|
)] |
34
|
|
|
#[Table(name: 'district')] |
35
|
|
|
#[Index(name: 'city_id', columns: ['city_id'])] |
36
|
|
|
#[EntityListeners([LogListener::class])] |
37
|
|
|
#[Entity(repositoryClass: DistrictRepository::class)] |
38
|
|
|
class District |
39
|
|
|
{ |
40
|
|
|
#[Groups(['people:read', 'order_details:read', 'order:write', 'address:read'])] |
41
|
|
|
#[Column(name: 'id', type: 'integer', nullable: false)] |
42
|
|
|
#[Id] |
43
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
44
|
|
|
private int $id = 0; |
45
|
|
|
|
46
|
|
|
#[Groups(['people:read', 'order_details:read', 'order:write', 'address:read'])] |
47
|
|
|
#[Column(name: 'district', type: 'string', length: 255, nullable: false)] |
48
|
|
|
private string $district; |
49
|
|
|
|
50
|
|
|
#[Groups(['people:read', 'order_details:read', 'order:write', 'address:read'])] |
51
|
|
|
#[JoinColumn(name: 'city_id', referencedColumnName: 'id', nullable: false)] |
52
|
|
|
#[ManyToOne(targetEntity: City::class, inversedBy: 'district')] |
53
|
|
|
private City $city; |
54
|
|
|
|
55
|
|
|
#[OneToMany(targetEntity: Street::class, mappedBy: 'district')] |
56
|
|
|
private Collection $street; |
57
|
|
|
|
58
|
|
|
public function __construct() |
59
|
|
|
{ |
60
|
|
|
$this->street = new ArrayCollection(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getId(): int |
64
|
|
|
{ |
65
|
|
|
return $this->id; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function setDistrict(string $district): self |
69
|
|
|
{ |
70
|
|
|
$this->district = $district; |
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getDistrict(): string |
75
|
|
|
{ |
76
|
|
|
return strtoupper($this->district); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function setCity(City $city): self |
80
|
|
|
{ |
81
|
|
|
$this->city = $city; |
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getCity(): City |
86
|
|
|
{ |
87
|
|
|
return $this->city; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function addStreet(Street $street): self |
91
|
|
|
{ |
92
|
|
|
if (!$this->street->contains($street)) { |
93
|
|
|
$this->street[] = $street; |
94
|
|
|
} |
95
|
|
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function removeStreet(Street $street): self |
99
|
|
|
{ |
100
|
|
|
$this->street->removeElement($street); |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getStreet(): Collection |
105
|
|
|
{ |
106
|
|
|
return $this->street; |
107
|
|
|
} |
108
|
|
|
} |
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