1
|
|
|
<?php |
2
|
|
|
namespace ControleOnline\Entity; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
5
|
|
|
|
6
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
10
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
11
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
12
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
13
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
14
|
|
|
use ControleOnline\Entity\City; |
15
|
|
|
use ControleOnline\Entity\Country; |
16
|
|
|
use ControleOnline\Repository\StateRepository; |
17
|
|
|
use ControleOnline\Listener\LogListener; |
18
|
|
|
|
19
|
|
|
#[ORM\Table(name: 'state')] |
20
|
|
|
#[ORM\Index(name: 'country_id', columns: ['country_id'])] |
21
|
|
|
#[ORM\UniqueConstraint(name: 'UF', columns: ['UF'])] |
22
|
|
|
#[ORM\UniqueConstraint(name: 'cod_ibge', columns: ['cod_ibge'])] |
23
|
|
|
#[ORM\EntityListeners([LogListener::class])] |
24
|
|
|
#[ORM\Entity(repositoryClass: StateRepository::class)] |
25
|
|
|
#[ApiResource( |
26
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
27
|
|
|
normalizationContext: ['groups' => ['state:read']], |
28
|
|
|
denormalizationContext: ['groups' => ['state:write']], |
29
|
|
|
operations: [ |
30
|
|
|
new GetCollection(security: "is_granted('ROLE_CLIENT')"), |
31
|
|
|
new Get(security: "is_granted('ROLE_CLIENT')") |
32
|
|
|
] |
33
|
|
|
)] |
34
|
|
|
#[ApiFilter(OrderFilter::class, properties: ['state' => 'ASC'])] |
35
|
|
|
class State |
36
|
|
|
{ |
37
|
|
|
#[ORM\Column(name: 'id', type: 'integer', nullable: false)] |
38
|
|
|
#[ORM\Id] |
39
|
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')] |
40
|
|
|
#[Groups(['city:read', 'logistic:read', 'state:read', 'order_details:read', 'order:write', 'people:read', 'address:read', 'delivery_region:read'])] |
41
|
|
|
private $id; |
42
|
|
|
|
43
|
|
|
#[ORM\Column(name: 'state', type: 'string', length: 50, nullable: false)] |
44
|
|
|
#[Groups(['city:read', 'logistic:read', 'state:read', 'order_details:read', 'order:write', 'people:read', 'address:read', 'delivery_region:read'])] |
45
|
|
|
private $state; |
46
|
|
|
|
47
|
|
|
#[ORM\Column(name: 'cod_ibge', type: 'integer', nullable: true)] |
48
|
|
|
#[Groups(['city:read', 'logistic:read', 'state:read', 'order_details:read', 'order:write', 'people:read', 'address:read', 'delivery_region:read'])] |
49
|
|
|
private $cod_ibge; |
50
|
|
|
|
51
|
|
|
#[ORM\Column(name: 'UF', type: 'string', length: 2, nullable: false)] |
52
|
|
|
#[Groups(['city:read', 'logistic:read', 'state:read', 'order_details:read', 'order:write', 'people:read', 'address:read', 'delivery_region:read'])] |
53
|
|
|
private $uf; |
54
|
|
|
|
55
|
|
|
#[ORM\ManyToOne(targetEntity: Country::class, inversedBy: 'state')] |
56
|
|
|
#[ORM\JoinColumn(name: 'country_id', referencedColumnName: 'id', nullable: false)] |
57
|
|
|
#[Groups(['city:read', 'logistic:read', 'state:read', 'order_details:read', 'order:write', 'people:read', 'address:read', 'delivery_region:read'])] |
58
|
|
|
private $country; |
59
|
|
|
|
60
|
|
|
#[ORM\OneToMany(targetEntity: City::class, mappedBy: 'state')] |
61
|
|
|
private $city; |
62
|
|
|
|
63
|
|
|
public function __construct() |
64
|
|
|
{ |
65
|
|
|
$this->city = new ArrayCollection(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getId() |
69
|
|
|
{ |
70
|
|
|
return $this->id; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function setState($state) |
74
|
|
|
{ |
75
|
|
|
$this->state = $state; |
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function getState() |
80
|
|
|
{ |
81
|
|
|
return strtoupper($this->state); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function setUf($uf) |
85
|
|
|
{ |
86
|
|
|
$this->uf = $uf; |
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function getUf() |
91
|
|
|
{ |
92
|
|
|
return strtoupper($this->uf); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function setCountry(Country $country = null) |
96
|
|
|
{ |
97
|
|
|
$this->country = $country; |
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function getCountry() |
102
|
|
|
{ |
103
|
|
|
return $this->country; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function addCity(City $city) |
107
|
|
|
{ |
108
|
|
|
$this->city[] = $city; |
109
|
|
|
return $this; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function removeCity(City $city) |
113
|
|
|
{ |
114
|
|
|
$this->city->removeElement($city); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function getCity() |
118
|
|
|
{ |
119
|
|
|
return $this->city; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function setIbge($cod_ibge) |
123
|
|
|
{ |
124
|
|
|
$this->cod_ibge = $cod_ibge; |
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function getIbge() |
129
|
|
|
{ |
130
|
|
|
return $this->cod_ibge; |
131
|
|
|
} |
132
|
|
|
} |
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