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