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