1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ControleOnline\Repository\CepRepository; |
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 Doctrine\ORM\Mapping\Column; |
|
|
|
|
14
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
|
|
|
15
|
|
|
use Doctrine\ORM\Mapping\EntityListeners; |
|
|
|
|
16
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
|
|
|
17
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
|
|
|
18
|
|
|
use Doctrine\ORM\Mapping\OneToMany; |
|
|
|
|
19
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
|
|
|
20
|
|
|
use Doctrine\ORM\Mapping\UniqueConstraint; |
|
|
|
|
21
|
|
|
|
22
|
|
|
#[ApiResource( |
23
|
|
|
operations: [new Get(security: 'is_granted(\'ROLE_CLIENT\')')], |
24
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
25
|
|
|
normalizationContext: ['groups' => ['cep:read']], |
26
|
|
|
denormalizationContext: ['groups' => ['cep:write']] |
27
|
|
|
)] |
28
|
|
|
#[Table(name: 'cep')] |
29
|
|
|
#[UniqueConstraint(name: 'CEP', columns: ['cep'])] |
30
|
|
|
#[EntityListeners([LogListener::class])] |
31
|
|
|
#[Entity(repositoryClass: CepRepository::class)] |
32
|
|
|
class Cep |
33
|
|
|
{ |
34
|
|
|
#[Groups(['people:read', 'order_details:read', 'order:write', 'address:read'])] |
35
|
|
|
#[Column(name: 'id', type: 'integer', nullable: false)] |
36
|
|
|
#[Id] |
37
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
38
|
|
|
private int $id = 0; |
39
|
|
|
|
40
|
|
|
#[Groups(['people:read', 'order_details:read', 'order:write', 'address:read'])] |
41
|
|
|
#[Column(name: 'cep', type: 'integer', nullable: false)] |
42
|
|
|
private int $cep; |
43
|
|
|
|
44
|
|
|
#[OneToMany(targetEntity: Street::class, mappedBy: 'cep')] |
45
|
|
|
private Collection $street; |
46
|
|
|
|
47
|
|
|
public function __construct() |
48
|
|
|
{ |
49
|
|
|
$this->street = new ArrayCollection(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getId(): int |
53
|
|
|
{ |
54
|
|
|
return $this->id; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function setCep(int $cep): self |
58
|
|
|
{ |
59
|
|
|
$this->cep = $cep; |
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getCep(): string |
64
|
|
|
{ |
65
|
|
|
return str_pad((string) $this->cep, 8, "0", STR_PAD_LEFT); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function addStreet(Street $street): self |
69
|
|
|
{ |
70
|
|
|
if (!$this->street->contains($street)) { |
71
|
|
|
$this->street[] = $street; |
72
|
|
|
} |
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function removeStreet(Street $street): self |
77
|
|
|
{ |
78
|
|
|
$this->street->removeElement($street); |
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getStreet(): Collection |
83
|
|
|
{ |
84
|
|
|
return $this->street; |
85
|
|
|
} |
86
|
|
|
} |
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