1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
12
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
13
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
14
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
15
|
|
|
use ControleOnline\Repository\ProductFileRepository; |
16
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
17
|
|
|
|
18
|
|
|
#[ApiResource( |
19
|
|
|
operations: [ |
20
|
|
|
new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'), |
21
|
|
|
new Put( |
22
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
23
|
|
|
denormalizationContext: ['groups' => ['product_file:write']] |
24
|
|
|
), |
25
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
26
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
27
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')') |
28
|
|
|
], |
29
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
30
|
|
|
normalizationContext: ['groups' => ['product_file:read']], |
31
|
|
|
denormalizationContext: ['groups' => ['product_file:write']] |
32
|
|
|
)] |
33
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['file' => 'exact', 'file.fileType' => 'exact', 'product' => 'exact'])] |
34
|
|
|
#[ORM\Table(name: 'product_file')] |
35
|
|
|
#[ORM\Index(name: 'file_id', columns: ['file_id'])] |
36
|
|
|
#[ORM\Index(name: 'IDX_CDFC73564584665B', columns: ['product_id'])] |
37
|
|
|
#[ORM\UniqueConstraint(name: 'product_id', columns: ['product_id', 'file_id'])] |
38
|
|
|
#[ORM\Entity(repositoryClass: ProductFileRepository::class)] |
39
|
|
|
class ProductFile |
40
|
|
|
{ |
41
|
|
|
#[ORM\Column(name: 'id', type: 'integer', nullable: false)] |
42
|
|
|
#[ORM\Id] |
43
|
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')] |
44
|
|
|
#[Groups(['product:read', 'order_product:read', 'order_details:read', 'order:write', 'product_file:read', 'product_category:read'])] |
45
|
|
|
private int $id = 0; |
46
|
|
|
|
47
|
|
|
#[ORM\JoinColumn(name: 'file_id', referencedColumnName: 'id')] |
48
|
|
|
#[ORM\ManyToOne(targetEntity: File::class)] |
49
|
|
|
#[Groups(['product:read', 'order_product:read', 'order_details:read', 'order:write', 'product_file:read', 'product_file:write', 'product_category:read'])] |
50
|
|
|
private File $file; |
|
|
|
|
51
|
|
|
|
52
|
|
|
#[ORM\JoinColumn(name: 'product_id', referencedColumnName: 'id')] |
53
|
|
|
#[ORM\ManyToOne(targetEntity: Product::class)] |
54
|
|
|
#[Groups(['product_file:read', 'product_file:write'])] |
55
|
|
|
private Product $product; |
56
|
|
|
|
57
|
|
|
public function getId(): int |
58
|
|
|
{ |
59
|
|
|
return $this->id; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getFile(): File |
63
|
|
|
{ |
64
|
|
|
return $this->file; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function setFile(File $file): self |
68
|
|
|
{ |
69
|
|
|
$this->file = $file; |
70
|
|
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getProduct(): Product |
74
|
|
|
{ |
75
|
|
|
return $this->product; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function setProduct(Product $product): self |
79
|
|
|
{ |
80
|
|
|
$this->product = $product; |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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