|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
|
|
6
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
|
|
|
|
|
|
9
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
|
|
11
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
|
12
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Document |
|
15
|
|
|
* |
|
16
|
|
|
* @ORM\EntityListeners ({App\Listener\LogListener::class}) |
|
17
|
|
|
* @ORM\Table (name="document", uniqueConstraints={@ORM\UniqueConstraint (name="doc", columns={"document", "document_type_id"})}, indexes={@ORM\Index (name="type_2", columns={"document_type_id"}), @ORM\Index(name="file_id", columns={"file_id"}), @ORM\Index(name="type", columns={"people_id", "document_type_id"})}) |
|
18
|
|
|
* @ORM\Entity (repositoryClass="ControleOnline\Repository\DocumentRepository") |
|
19
|
|
|
*/ |
|
20
|
|
|
#[ApiResource(operations: [new Get(security: 'is_granted(\'ROLE_CLIENT\')'), new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')')], formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], normalizationContext: ['groups' => ['document_read']], denormalizationContext: ['groups' => ['document_write']])] |
|
21
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])] |
|
22
|
|
|
class Document |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var integer |
|
26
|
|
|
* |
|
27
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
|
28
|
|
|
* @ORM\Id |
|
29
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
|
30
|
|
|
*/ |
|
31
|
|
|
private $id; |
|
32
|
|
|
/** |
|
33
|
|
|
* @var integer |
|
34
|
|
|
* |
|
35
|
|
|
* @ORM\Column(name="document", type="bigint", nullable=false) |
|
36
|
|
|
* @Groups({"people_read", "document_read", "carrier_read", "provider_read"}) |
|
37
|
|
|
*/ |
|
38
|
|
|
private $document; |
|
39
|
|
|
/** |
|
40
|
|
|
* @var \ControleOnline\Entity\People |
|
41
|
|
|
* |
|
42
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People", inversedBy="document") |
|
43
|
|
|
* @ORM\JoinColumns({ |
|
44
|
|
|
* @ORM\JoinColumn(name="people_id", referencedColumnName="id", nullable=false) |
|
45
|
|
|
* }) |
|
46
|
|
|
* @Groups({"document_read"}) |
|
47
|
|
|
*/ |
|
48
|
|
|
private $people; |
|
49
|
|
|
/** |
|
50
|
|
|
* @var \ControleOnline\Entity\File |
|
|
|
|
|
|
51
|
|
|
* |
|
52
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File") |
|
53
|
|
|
* @ORM\JoinColumns({ |
|
54
|
|
|
* @ORM\JoinColumn(name="file_id", referencedColumnName="id", nullable=true) |
|
55
|
|
|
* }) |
|
56
|
|
|
*/ |
|
57
|
|
|
private $file; |
|
58
|
|
|
/** |
|
59
|
|
|
* @var \ControleOnline\Entity\DocumentType |
|
60
|
|
|
* |
|
61
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\DocumentType") |
|
62
|
|
|
* @ORM\JoinColumns({ |
|
63
|
|
|
* @ORM\JoinColumn(name="document_type_id", referencedColumnName="id", nullable=false) |
|
64
|
|
|
* }) |
|
65
|
|
|
* @Groups({"people_read", "document_read", "carrier_read"}) |
|
66
|
|
|
*/ |
|
67
|
|
|
private $documentType; |
|
68
|
|
|
/** |
|
69
|
|
|
* Get id |
|
70
|
|
|
* |
|
71
|
|
|
* @return integer |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getId() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->id; |
|
76
|
|
|
} |
|
77
|
|
|
/** |
|
78
|
|
|
* Set document |
|
79
|
|
|
* |
|
80
|
|
|
* @param integer $document |
|
81
|
|
|
* @return Document |
|
82
|
|
|
*/ |
|
83
|
|
|
public function setDocument($document) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->document = $document; |
|
86
|
|
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
/** |
|
89
|
|
|
* Get document |
|
90
|
|
|
* |
|
91
|
|
|
* @return integer |
|
92
|
|
|
*/ |
|
93
|
|
|
public function getDocument() |
|
94
|
|
|
{ |
|
95
|
|
|
$document = (string) $this->document; |
|
96
|
|
|
// CPF |
|
97
|
|
|
if ($this->getDocumentType()->getDocumentType() == 'CPF') { |
|
98
|
|
|
return str_pad($document, 11, '0', STR_PAD_LEFT); |
|
|
|
|
|
|
99
|
|
|
} |
|
100
|
|
|
// CNPJ |
|
101
|
|
|
if ($this->getDocumentType()->getDocumentType() == 'CNPJ') { |
|
102
|
|
|
return str_pad($document, 14, '0', STR_PAD_LEFT); |
|
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
return $this->document; |
|
105
|
|
|
} |
|
106
|
|
|
/** |
|
107
|
|
|
* Set file |
|
108
|
|
|
* |
|
109
|
|
|
* @param \ControleOnline\Entity\File $file |
|
110
|
|
|
* @return People |
|
111
|
|
|
*/ |
|
112
|
|
|
public function setFile(\ControleOnline\Entity\File $file = null) |
|
113
|
|
|
{ |
|
114
|
|
|
$this->file = $file; |
|
115
|
|
|
return $this; |
|
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
/** |
|
118
|
|
|
* Get file |
|
119
|
|
|
* |
|
120
|
|
|
* @return \ControleOnline\Entity\File |
|
121
|
|
|
*/ |
|
122
|
|
|
public function getFile() |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->file; |
|
125
|
|
|
} |
|
126
|
|
|
/** |
|
127
|
|
|
* Set people |
|
128
|
|
|
* |
|
129
|
|
|
* @return Document |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setPeople($people) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->people = $people; |
|
134
|
|
|
return $this; |
|
135
|
|
|
} |
|
136
|
|
|
/** |
|
137
|
|
|
* Get people |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getPeople() |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->people; |
|
142
|
|
|
} |
|
143
|
|
|
/** |
|
144
|
|
|
* Set documentType |
|
145
|
|
|
* |
|
146
|
|
|
* @param \ControleOnline\Entity\DocumentType $documentType |
|
147
|
|
|
* @return Document |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setDocumentType(\ControleOnline\Entity\DocumentType $documentType = null) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->documentType = $documentType; |
|
152
|
|
|
return $this; |
|
153
|
|
|
} |
|
154
|
|
|
/** |
|
155
|
|
|
* Get documentType |
|
156
|
|
|
* |
|
157
|
|
|
* @return \ControleOnline\Entity\DocumentType |
|
158
|
|
|
*/ |
|
159
|
|
|
public function getDocumentType() |
|
160
|
|
|
{ |
|
161
|
|
|
return $this->documentType; |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|
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