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
|
|
|
/** |
21
|
|
|
* File |
22
|
|
|
* |
23
|
|
|
* @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class}) |
24
|
|
|
* @ORM\Entity (repositoryClass="ControleOnline\Repository\FileRepository") |
25
|
|
|
* @ORM\Table (name="files", uniqueConstraints={@ORM\UniqueConstraint (name="url", columns={"url"}), @ORM\UniqueConstraint(name="path", columns={"path"})}) |
26
|
|
|
*/ |
27
|
|
|
#[ApiResource( |
28
|
|
|
operations: [ |
29
|
|
|
new Get(security: 'is_granted(\'ROLE_CLIENT\')'), |
30
|
|
|
new Get( |
31
|
|
|
security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')', |
32
|
|
|
uriTemplate: '/files/download/{id}', |
33
|
|
|
controller: GetFileDataAction::class |
34
|
|
|
), |
35
|
|
|
new Post( |
36
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
37
|
|
|
uriTemplate: '/files/upload', |
38
|
|
|
controller: FileUploadController::class, |
39
|
|
|
deserialize: false |
40
|
|
|
), |
41
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')') |
42
|
|
|
], |
43
|
|
|
|
44
|
|
|
normalizationContext: ['groups' => ['file_read']], |
45
|
|
|
denormalizationContext: ['groups' => ['file_write']] |
46
|
|
|
)] |
47
|
|
|
class File |
48
|
|
|
{ |
49
|
|
|
/** |
50
|
|
|
* |
51
|
|
|
* @ORM\Column(type="integer", nullable=false) |
52
|
|
|
* @ORM\Id |
53
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
54
|
|
|
* @Groups({"file_read","people_read"}) |
55
|
|
|
*/ |
56
|
|
|
private $id; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @ORM\Column(type="string", length=255, nullable=false) |
60
|
|
|
* @Groups({"file_read","people_read"}) |
61
|
|
|
*/ |
62
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['file_type' => 'exact'])] |
63
|
|
|
private $file_type; |
64
|
|
|
/** |
65
|
|
|
* @ORM\Column(type="string", length=255, nullable=false) |
66
|
|
|
*/ |
67
|
|
|
private $content; |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var \ControleOnline\Entity\People |
|
|
|
|
72
|
|
|
* |
73
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
74
|
|
|
* @ORM\JoinColumns({ |
75
|
|
|
* @ORM\JoinColumn(name="people_id", referencedColumnName="id") |
76
|
|
|
* }) |
77
|
|
|
* @Groups({"file_read"}) |
78
|
|
|
*/ |
79
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])] |
80
|
|
|
|
81
|
|
|
private $people; |
82
|
|
|
|
83
|
|
|
public function __construct() |
84
|
|
|
{ |
85
|
|
|
$this->people = new \Doctrine\Common\Collections\ArrayCollection(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getId() |
89
|
|
|
{ |
90
|
|
|
return $this->id; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get the value of file_type |
97
|
|
|
*/ |
98
|
|
|
public function getFileType() |
99
|
|
|
{ |
100
|
|
|
return $this->file_type; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Set the value of file_type |
105
|
|
|
*/ |
106
|
|
|
public function setFileType($file_type): self |
107
|
|
|
{ |
108
|
|
|
$this->file_type = $file_type; |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get the value of content |
115
|
|
|
*/ |
116
|
|
|
public function getContent() |
117
|
|
|
{ |
118
|
|
|
return $this->content; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Set the value of content |
123
|
|
|
*/ |
124
|
|
|
public function setContent($content): self |
125
|
|
|
{ |
126
|
|
|
$this->content = $content; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Get the value of people |
133
|
|
|
*/ |
134
|
|
|
public function getPeople() |
135
|
|
|
{ |
136
|
|
|
return $this->people; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set the value of people |
141
|
|
|
*/ |
142
|
|
|
public function setPeople($people): self |
143
|
|
|
{ |
144
|
|
|
$this->people = $people; |
145
|
|
|
|
146
|
|
|
return $this; |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|
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