|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use ControleOnline\Repository\FileRepository; |
|
8
|
|
|
use ControleOnline\Listener\LogListener; |
|
9
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
|
|
15
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
|
|
16
|
|
|
use ControleOnline\Controller\GetFileDataAction; |
|
17
|
|
|
use ControleOnline\Controller\FileUploadController; |
|
18
|
|
|
use ControleOnline\Controller\FileConvertController; |
|
19
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
|
|
|
|
|
20
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
|
|
|
|
|
21
|
|
|
use Doctrine\ORM\Mapping\EntityListeners; |
|
|
|
|
|
|
22
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
|
|
|
|
|
23
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
|
|
|
|
|
24
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
|
|
|
|
|
25
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
|
|
|
|
|
26
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
|
|
|
|
|
27
|
|
|
use Doctrine\ORM\Mapping\UniqueConstraint; |
|
|
|
|
|
|
28
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
|
|
29
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank; |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
#[ApiResource( |
|
32
|
|
|
operations: [ |
|
33
|
|
|
new Get( |
|
34
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
|
35
|
|
|
normalizationContext: ['groups' => ['file_item:read']], |
|
36
|
|
|
), |
|
37
|
|
|
new Get( |
|
38
|
|
|
security: 'is_granted(\'PUBLIC_ACCESS\')', |
|
39
|
|
|
uriTemplate: '/files/{id}/download', |
|
40
|
|
|
controller: GetFileDataAction::class |
|
41
|
|
|
), |
|
42
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
|
43
|
|
|
new Post( |
|
44
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
|
45
|
|
|
uriTemplate: '/files/upload', |
|
46
|
|
|
controller: FileUploadController::class, |
|
47
|
|
|
deserialize: false |
|
48
|
|
|
), |
|
49
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'), |
|
50
|
|
|
new Post(security: 'is_granted(\'ROLE_CLIENT\')'), |
|
51
|
|
|
new Put( |
|
52
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
|
53
|
|
|
validationContext: ['groups' => ['file:write']], |
|
54
|
|
|
denormalizationContext: ['groups' => ['file:write']] |
|
55
|
|
|
), |
|
56
|
|
|
new Post( |
|
57
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
|
58
|
|
|
uriTemplate: '/files/{id}/convert', |
|
59
|
|
|
controller: FileConvertController::class, |
|
60
|
|
|
deserialize: false |
|
61
|
|
|
), |
|
62
|
|
|
], |
|
63
|
|
|
normalizationContext: ['groups' => ['file:read']], |
|
64
|
|
|
denormalizationContext: ['groups' => ['file:write']] |
|
65
|
|
|
)] |
|
66
|
|
|
#[Table(name: 'files')] |
|
67
|
|
|
#[UniqueConstraint(name: 'url', columns: ['url'])] |
|
68
|
|
|
#[UniqueConstraint(name: 'path', columns: ['path'])] |
|
69
|
|
|
#[EntityListeners([LogListener::class])] |
|
70
|
|
|
#[Entity(repositoryClass: FileRepository::class)] |
|
71
|
|
|
class File |
|
72
|
|
|
{ |
|
73
|
|
|
#[Groups(['file:read', 'spool:read', 'order_details:read', 'order:write', 'category:read', 'product_category:read', 'order_product:read', 'product_file:read', 'product:read', 'spool_item:read', 'file_item:read', 'contract:read', 'model:read', 'people:read'])] |
|
74
|
|
|
#[Column(type: 'integer', nullable: false)] |
|
75
|
|
|
#[Id] |
|
76
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
|
77
|
|
|
private int $id = 0; |
|
78
|
|
|
|
|
79
|
|
|
#[Groups(['file:read', 'spool:read', 'order_details:read', 'order:write', 'category:read', 'product_category:read', 'order_product:read', 'product_file:read', 'product:read', 'spool_item:read', 'file_item:read', 'file:write', 'contract:read', 'model:read', 'people:read'])] |
|
80
|
|
|
#[NotBlank] |
|
81
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['fileType' => 'exact'])] |
|
82
|
|
|
#[Column(type: 'string', length: 255, nullable: false)] |
|
83
|
|
|
private string $fileType; |
|
84
|
|
|
|
|
85
|
|
|
#[Groups(['file:read', 'spool:read', 'order_details:read', 'order:write', 'category:read', 'product_category:read', 'order_product:read', 'product_file:read', 'product:read', 'spool_item:read', 'file_item:read', 'file:write', 'contract:read', 'model:read', 'people:read'])] |
|
86
|
|
|
#[NotBlank] |
|
87
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['fileName' => 'exact'])] |
|
88
|
|
|
#[Column(type: 'string', length: 255, nullable: false)] |
|
89
|
|
|
private string $fileName; |
|
90
|
|
|
|
|
91
|
|
|
#[Groups(['file:read', 'spool:read', 'order_details:read', 'order:write', 'category:read', 'product_category:read', 'order_product:read', 'product_file:read', 'product:read', 'spool_item:read', 'file_item:read', 'file:write', 'contract:read', 'model:read', 'people:read'])] |
|
92
|
|
|
#[NotBlank] |
|
93
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['context' => 'exact'])] |
|
94
|
|
|
#[Column(type: 'string', length: 255, nullable: false)] |
|
95
|
|
|
private string $context; |
|
96
|
|
|
|
|
97
|
|
|
#[Groups(['file:read', 'spool:read', 'order_details:read', 'order:write', 'category:read', 'product_category:read', 'order_product:read', 'product_file:read', 'product:read', 'spool_item:read', 'file_item:read', 'file:write', 'contract:read', 'model:read', 'people:read'])] |
|
98
|
|
|
#[NotBlank] |
|
99
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['extension' => 'exact'])] |
|
100
|
|
|
#[Column(type: 'string', length: 255, nullable: false)] |
|
101
|
|
|
private string $extension; |
|
102
|
|
|
|
|
103
|
|
|
#[Groups(['spool_item:read', 'file_item:read', 'file:write'])] |
|
104
|
|
|
#[Column(type: 'string', length: 255, nullable: false)] |
|
105
|
|
|
private string $content; |
|
106
|
|
|
|
|
107
|
|
|
#[Groups(['spool_item:read', 'file_item:read', 'file:write', 'file:read'])] |
|
108
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])] |
|
109
|
|
|
#[JoinColumn(name: 'people_id', referencedColumnName: 'id', nullable: true)] |
|
110
|
|
|
#[ManyToOne(targetEntity: People::class)] |
|
111
|
|
|
private ?People $people = null; |
|
|
|
|
|
|
112
|
|
|
|
|
113
|
|
|
public function __construct() |
|
114
|
|
|
{ |
|
115
|
|
|
// Constructor remains empty after removing incorrect collection initialization |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function getId(): int |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->id; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function getFileType(): string |
|
124
|
|
|
{ |
|
125
|
|
|
return $this->fileType; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
public function setFileType(string $fileType): self |
|
129
|
|
|
{ |
|
130
|
|
|
$this->fileType = $fileType; |
|
131
|
|
|
return $this; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getContent(): string |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->content; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function setContent(string $content): self |
|
140
|
|
|
{ |
|
141
|
|
|
$this->content = $content; |
|
142
|
|
|
return $this; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
public function getPeople(): ?People |
|
146
|
|
|
{ |
|
147
|
|
|
return $this->people; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
public function setPeople(?People $people): self |
|
151
|
|
|
{ |
|
152
|
|
|
$this->people = $people; |
|
153
|
|
|
return $this; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
public function getExtension(): string |
|
157
|
|
|
{ |
|
158
|
|
|
return $this->extension; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
public function setExtension(string $extension): self |
|
162
|
|
|
{ |
|
163
|
|
|
$this->extension = $extension; |
|
164
|
|
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
public function getFileName(): string |
|
168
|
|
|
{ |
|
169
|
|
|
return $this->fileName; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
public function setFileName(string $fileName): self |
|
173
|
|
|
{ |
|
174
|
|
|
$this->fileName = $fileName; |
|
175
|
|
|
return $this; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
public function getContext(): string |
|
179
|
|
|
{ |
|
180
|
|
|
return $this->context; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
public function setContext(string $context): self |
|
184
|
|
|
{ |
|
185
|
|
|
$this->context = $context; |
|
186
|
|
|
return $this; |
|
187
|
|
|
} |
|
188
|
|
|
} |
|
189
|
|
|
|
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