|
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\Get; |
|
|
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
|
|
14
|
|
|
use ControleOnline\Listener\LogListener; |
|
|
|
|
|
|
15
|
|
|
use ControleOnline\Repository\DocumentRepository; |
|
16
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
#[ApiResource( |
|
20
|
|
|
operations: [ |
|
21
|
|
|
new Get(security: 'is_granted(\'ROLE_CLIENT\')'), |
|
22
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'), |
|
23
|
|
|
new Put( |
|
24
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
|
25
|
|
|
validationContext: ['groups' => ['document:read']], |
|
26
|
|
|
denormalizationContext: ['groups' => ['document:write']] |
|
27
|
|
|
), |
|
28
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
|
29
|
|
|
new Delete(security: "is_granted('ROLE_CLIENT')") |
|
30
|
|
|
], |
|
31
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
|
32
|
|
|
normalizationContext: ['groups' => ['document:read']], |
|
33
|
|
|
denormalizationContext: ['groups' => ['document:write']] |
|
34
|
|
|
)] |
|
35
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])] |
|
36
|
|
|
#[ORM\Table(name: 'document')] |
|
37
|
|
|
#[ORM\Index(name: 'type_2', columns: ['document_type_id'])] |
|
38
|
|
|
#[ORM\Index(name: 'file_id', columns: ['file_id'])] |
|
39
|
|
|
#[ORM\Index(name: 'type', columns: ['people_id', 'document_type_id'])] |
|
40
|
|
|
#[ORM\UniqueConstraint(name: 'doc', columns: ['document', 'document_type_id'])] |
|
41
|
|
|
#[ORM\EntityListeners([LogListener::class])] |
|
42
|
|
|
#[ORM\Entity(repositoryClass: DocumentRepository::class)] |
|
43
|
|
|
class Document |
|
44
|
|
|
{ |
|
45
|
|
|
#[ORM\Column(name: 'id', type: 'integer', nullable: false)] |
|
46
|
|
|
#[ORM\Id] |
|
47
|
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')] |
|
48
|
|
|
private int $id = 0; |
|
49
|
|
|
|
|
50
|
|
|
#[ORM\Column(name: 'document', type: 'bigint', nullable: false)] |
|
51
|
|
|
#[Groups(['people:read', 'document:read', 'carrier:read', 'provider:read', 'document:write'])] |
|
52
|
|
|
private int $document; |
|
53
|
|
|
|
|
54
|
|
|
#[ORM\JoinColumn(name: 'people_id', referencedColumnName: 'id', nullable: false)] |
|
55
|
|
|
#[ORM\ManyToOne(targetEntity: People::class, inversedBy: 'document')] |
|
56
|
|
|
#[Groups(['document:read', 'document:write'])] |
|
57
|
|
|
private People $people; |
|
58
|
|
|
|
|
59
|
|
|
#[ORM\JoinColumn(name: 'file_id', referencedColumnName: 'id', nullable: true)] |
|
60
|
|
|
#[ORM\ManyToOne(targetEntity: File::class)] |
|
61
|
|
|
#[Groups(['document:read', 'document:write'])] |
|
62
|
|
|
private ?File $file = null; |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
#[ORM\JoinColumn(name: 'document_type_id', referencedColumnName: 'id', nullable: false)] |
|
65
|
|
|
#[ORM\ManyToOne(targetEntity: DocumentType::class)] |
|
66
|
|
|
#[Groups(['people:read', 'document:read', 'carrier:read', 'document:write'])] |
|
67
|
|
|
private DocumentType $documentType; |
|
68
|
|
|
|
|
69
|
|
|
public function getId(): int |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->id; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function setDocument(int $document): self |
|
75
|
|
|
{ |
|
76
|
|
|
$this->document = $document; |
|
77
|
|
|
return $this; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function getDocument(): string |
|
81
|
|
|
{ |
|
82
|
|
|
$document = (string) $this->document; |
|
83
|
|
|
if ($this->getDocumentType()->getDocumentType() === 'CPF') { |
|
84
|
|
|
return str_pad($document, 11, '0', STR_PAD_LEFT); |
|
85
|
|
|
} |
|
86
|
|
|
if ($this->getDocumentType()->getDocumentType() === 'CNPJ') { |
|
87
|
|
|
return str_pad($document, 14, '0', STR_PAD_LEFT); |
|
88
|
|
|
} |
|
89
|
|
|
return $document; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function setFile(?File $file): self |
|
93
|
|
|
{ |
|
94
|
|
|
$this->file = $file; |
|
95
|
|
|
return $this; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function getFile(): ?File |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->file; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function setPeople(People $people): self |
|
104
|
|
|
{ |
|
105
|
|
|
$this->people = $people; |
|
106
|
|
|
return $this; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function getPeople(): People |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->people; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function setDocumentType(DocumentType $documentType): self |
|
115
|
|
|
{ |
|
116
|
|
|
$this->documentType = $documentType; |
|
117
|
|
|
return $this; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function getDocumentType(): DocumentType |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->documentType; |
|
123
|
|
|
} |
|
124
|
|
|
} |
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