1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
14
|
|
|
use ControleOnline\Listener\LogListener; |
15
|
|
|
use ControleOnline\Repository\ConnectionRepository; |
16
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
|
|
|
17
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
|
|
|
18
|
|
|
use Doctrine\ORM\Mapping\EntityListeners; |
|
|
|
|
19
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
|
|
|
20
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
|
|
|
21
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
|
|
|
22
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
|
|
|
23
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
|
|
|
24
|
|
|
|
25
|
|
|
#[ApiResource( |
26
|
|
|
operations: [ |
27
|
|
|
new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'), |
28
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
29
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'), |
30
|
|
|
new Post(security: 'is_granted(\'ROLE_CLIENT\')'), |
31
|
|
|
new Put( |
32
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
33
|
|
|
denormalizationContext: ['groups' => ['connections:write']] |
34
|
|
|
), |
35
|
|
|
], |
36
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
37
|
|
|
normalizationContext: ['groups' => ['connections:read']], |
38
|
|
|
denormalizationContext: ['groups' => ['connections:write']] |
39
|
|
|
)] |
40
|
|
|
#[Table(name: 'connections')] |
41
|
|
|
#[EntityListeners([LogListener::class])] |
42
|
|
|
#[Entity(repositoryClass: ConnectionRepository::class)] |
43
|
|
|
class Connection |
44
|
|
|
{ |
45
|
|
|
#[Groups(['connections:read'])] |
46
|
|
|
#[Column(name: 'id', type: 'integer', nullable: false)] |
47
|
|
|
#[Id] |
48
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
49
|
|
|
private int $id = 0; |
50
|
|
|
|
51
|
|
|
#[Groups(['connections:read', 'connections:write'])] |
52
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])] |
53
|
|
|
#[JoinColumn(name: 'people_id', referencedColumnName: 'id', nullable: false)] |
54
|
|
|
#[ManyToOne(targetEntity: People::class)] |
55
|
|
|
private ?People $people = null; |
|
|
|
|
56
|
|
|
|
57
|
|
|
#[Groups(['connections:read', 'connections:write'])] |
58
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['status' => 'exact'])] |
59
|
|
|
#[JoinColumn(name: 'status_id', referencedColumnName: 'id', nullable: false)] |
60
|
|
|
#[ManyToOne(targetEntity: Status::class)] |
61
|
|
|
private ?Status $status = null; |
62
|
|
|
|
63
|
|
|
#[Groups(['connections:read', 'connections:write'])] |
64
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['name' => 'exact'])] |
65
|
|
|
#[Column(name: 'name', type: 'string', length: 50, nullable: false)] |
66
|
|
|
private string $name; |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
#[Groups(['connections:read', 'connections:write'])] |
70
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['type' => 'exact'])] |
71
|
|
|
#[Column(name: 'type', type: 'string', length: 50, nullable: true)] |
72
|
|
|
private string $type; |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
#[Groups(['connections:read', 'connections:write'])] |
76
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['phone' => 'exact'])] |
77
|
|
|
#[JoinColumn(name: 'phone_id', referencedColumnName: 'id', nullable: true)] |
78
|
|
|
#[ManyToOne(targetEntity: Phone::class)] |
79
|
|
|
private ?Phone $phone = null; |
|
|
|
|
80
|
|
|
|
81
|
|
|
#[Groups(['connections:read', 'connections:write'])] |
82
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['channel' => 'exact'])] |
83
|
|
|
#[Column(name: 'channel', type: 'string', columnDefinition: "ENUM('whatsapp')", nullable: false)] |
84
|
|
|
private string $channel; |
85
|
|
|
|
86
|
|
|
// Getters e Setters |
87
|
|
|
|
88
|
|
|
public function getId(): int |
89
|
|
|
{ |
90
|
|
|
return $this->id; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getPeople(): ?People |
94
|
|
|
{ |
95
|
|
|
return $this->people; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function setPeople(?People $people): self |
99
|
|
|
{ |
100
|
|
|
$this->people = $people; |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getStatus(): ?Status |
105
|
|
|
{ |
106
|
|
|
return $this->status; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function setStatus(?Status $status): self |
110
|
|
|
{ |
111
|
|
|
$this->status = $status; |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getName(): string |
116
|
|
|
{ |
117
|
|
|
return $this->name; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function setName(string $name): self |
121
|
|
|
{ |
122
|
|
|
$this->name = $name; |
123
|
|
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function getPhone(): ?Phone |
127
|
|
|
{ |
128
|
|
|
return $this->phone; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function setPhone(?Phone $phone): self |
132
|
|
|
{ |
133
|
|
|
$this->phone = $phone; |
134
|
|
|
return $this; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function getChannel(): string |
138
|
|
|
{ |
139
|
|
|
return $this->channel; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function setChannel(string $channel): self |
143
|
|
|
{ |
144
|
|
|
$this->channel = $channel; |
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function getType(): ?string |
149
|
|
|
{ |
150
|
|
|
return $this->type; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function setType(?string $type): self |
154
|
|
|
{ |
155
|
|
|
$this->type = $type; |
156
|
|
|
|
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
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