1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
6
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
13
|
|
|
use ControleOnline\Controller\GetFileDataAction; |
14
|
|
|
use ControleOnline\Controller\FileUploadController; |
15
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
16
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
|
17
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
18
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
|
19
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
20
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter; |
|
|
|
|
21
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
22
|
|
|
use ControleOnline\Controller\FileConvertController; |
23
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
|
|
|
24
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* File |
28
|
|
|
* |
29
|
|
|
* @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class}) |
30
|
|
|
* @ORM\Entity (repositoryClass="ControleOnline\Repository\FileRepository") |
31
|
|
|
* @ORM\Table (name="files", uniqueConstraints={@ORM\UniqueConstraint (name="url", columns={"url"}), @ORM\UniqueConstraint(name="path", columns={"path"})}) |
32
|
|
|
*/ |
33
|
|
|
#[ApiResource( |
34
|
|
|
operations: [ |
35
|
|
|
new Get( |
36
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
37
|
|
|
normalizationContext: ['groups' => ['file_item:read']], |
38
|
|
|
), |
39
|
|
|
new Get( |
40
|
|
|
security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')', |
41
|
|
|
uriTemplate: '/files/{id}/download', |
42
|
|
|
controller: GetFileDataAction::class |
43
|
|
|
), |
44
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
45
|
|
|
new Post( |
46
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
47
|
|
|
uriTemplate: '/files/upload', |
48
|
|
|
controller: FileUploadController::class, |
49
|
|
|
deserialize: false |
50
|
|
|
), |
51
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'), |
52
|
|
|
new Post(security: 'is_granted(\'ROLE_CLIENT\')'), |
53
|
|
|
new Put( |
54
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
55
|
|
|
validationContext: ['groups' => ['file:write']], |
56
|
|
|
denormalizationContext: ['groups' => ['file:write']] |
57
|
|
|
), |
58
|
|
|
new Post( |
59
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
60
|
|
|
uriTemplate: '/files/{id}/convert', |
61
|
|
|
controller: FileConvertController::class, |
62
|
|
|
deserialize: false |
63
|
|
|
), |
64
|
|
|
], |
65
|
|
|
normalizationContext: ['groups' => ['file:read']], |
66
|
|
|
denormalizationContext: ['groups' => ['file:write']] |
67
|
|
|
)] |
68
|
|
|
class File |
69
|
|
|
{ |
70
|
|
|
/** |
71
|
|
|
* |
72
|
|
|
* @ORM\Column(type="integer", nullable=false) |
73
|
|
|
* @ORM\Id |
74
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
75
|
|
|
* @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","contract:read","model:read","people:read"}) |
76
|
|
|
*/ |
77
|
|
|
private $id; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @ORM\Column(type="string", length=255, nullable=false) |
81
|
|
|
* @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","file:write","contract:read","model:read","people:read"}) |
82
|
|
|
* @Assert\NotBlank |
83
|
|
|
*/ |
84
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['fileType' => 'exact'])] |
85
|
|
|
private $fileType; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @ORM\Column(type="string", length=255, nullable=false) |
89
|
|
|
* @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","file:write","contract:read","model:read","people:read"}) |
90
|
|
|
* @Assert\NotBlank |
91
|
|
|
*/ |
92
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['fileName' => 'exact'])] |
93
|
|
|
private $fileName; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @ORM\Column(type="string", length=255, nullable=false) |
97
|
|
|
* @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","file:write","contract:read","model:read","people:read"}) |
98
|
|
|
* @Assert\NotBlank |
99
|
|
|
*/ |
100
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['context' => 'exact'])] |
101
|
|
|
private $context; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @ORM\Column(type="string", length=255, nullable=false) |
105
|
|
|
* @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","file:write","contract:read","model:read","people:read"}) |
106
|
|
|
* @Assert\NotBlank |
107
|
|
|
*/ |
108
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['extension' => 'exact'])] |
109
|
|
|
private $extension; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @ORM\Column(type="string", length=255, nullable=false) |
113
|
|
|
* @Groups({"file_item:read","file:write"}) |
114
|
|
|
*/ |
115
|
|
|
private $content; |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @var \ControleOnline\Entity\People |
|
|
|
|
119
|
|
|
* |
120
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
121
|
|
|
* @ORM\JoinColumns({ |
122
|
|
|
* @ORM\JoinColumn(name="people_id", referencedColumnName="id") |
123
|
|
|
* }) |
124
|
|
|
* @Groups({"file_item:read","file:write","file:read"}) |
125
|
|
|
*/ |
126
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])] |
127
|
|
|
private $people; |
128
|
|
|
|
129
|
|
|
public function __construct() |
130
|
|
|
{ |
131
|
|
|
$this->people = new \Doctrine\Common\Collections\ArrayCollection(); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function getId() |
135
|
|
|
{ |
136
|
|
|
return $this->id; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
|
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Get the value of fileType |
143
|
|
|
*/ |
144
|
|
|
public function getFileType() |
145
|
|
|
{ |
146
|
|
|
return $this->fileType; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Set the value of fileType |
151
|
|
|
*/ |
152
|
|
|
public function setFileType($fileType): self |
153
|
|
|
{ |
154
|
|
|
$this->fileType = $fileType; |
155
|
|
|
|
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Get the value of content |
161
|
|
|
*/ |
162
|
|
|
public function getContent() |
163
|
|
|
{ |
164
|
|
|
return $this->content; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Set the value of content |
169
|
|
|
*/ |
170
|
|
|
public function setContent($content): self |
171
|
|
|
{ |
172
|
|
|
$this->content = $content; |
173
|
|
|
|
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Get the value of people |
179
|
|
|
*/ |
180
|
|
|
public function getPeople() |
181
|
|
|
{ |
182
|
|
|
return $this->people; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Set the value of people |
187
|
|
|
*/ |
188
|
|
|
public function setPeople($people): self |
189
|
|
|
{ |
190
|
|
|
$this->people = $people; |
191
|
|
|
|
192
|
|
|
return $this; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Get the value of extension |
197
|
|
|
*/ |
198
|
|
|
public function getExtension() |
199
|
|
|
{ |
200
|
|
|
return $this->extension; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Set the value of extension |
205
|
|
|
*/ |
206
|
|
|
public function setExtension($extension): self |
207
|
|
|
{ |
208
|
|
|
$this->extension = $extension; |
209
|
|
|
|
210
|
|
|
return $this; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Get the value of fileName |
215
|
|
|
*/ |
216
|
|
|
public function getFileName() |
217
|
|
|
{ |
218
|
|
|
return $this->fileName; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Set the value of fileName |
223
|
|
|
*/ |
224
|
|
|
public function setFileName($fileName): self |
225
|
|
|
{ |
226
|
|
|
$this->fileName = $fileName; |
227
|
|
|
|
228
|
|
|
return $this; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Get the value of context |
233
|
|
|
*/ |
234
|
|
|
public function getContext() |
235
|
|
|
{ |
236
|
|
|
return $this->context; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* Set the value of context |
241
|
|
|
*/ |
242
|
|
|
public function setContext($context): self |
243
|
|
|
{ |
244
|
|
|
$this->context = $context; |
245
|
|
|
|
246
|
|
|
return $this; |
247
|
|
|
} |
248
|
|
|
} |
249
|
|
|
|
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