1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
6
|
|
|
|
7
|
|
|
use ControleOnline\Repository\DeviceRepository; |
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 ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
17
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
18
|
|
|
use ControleOnline\DataProvider\PrinterDataProvider; |
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\Table; |
|
|
|
|
25
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank; |
|
|
|
|
26
|
|
|
|
27
|
|
|
#[ApiResource( |
28
|
|
|
operations: [ |
29
|
|
|
new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'), |
30
|
|
|
new Put( |
31
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
32
|
|
|
denormalizationContext: ['groups' => ['device:write']] |
33
|
|
|
), |
34
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
35
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
36
|
|
|
new GetCollection( |
37
|
|
|
security: 'is_granted(\'PUBLIC_ACCESS\')', |
38
|
|
|
), |
39
|
|
|
new GetCollection( |
40
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')', |
41
|
|
|
uriTemplate: '/printers', |
42
|
|
|
provider: PrinterDataProvider::class, |
43
|
|
|
normalizationContext: ['groups' => ['device:read']], |
44
|
|
|
), |
45
|
|
|
], |
46
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
47
|
|
|
normalizationContext: ['groups' => ['device:read']], |
48
|
|
|
denormalizationContext: ['groups' => ['device:write']] |
49
|
|
|
)] |
50
|
|
|
#[ApiFilter(filterClass: OrderFilter::class, properties: ['id' => 'ASC'])] |
51
|
|
|
#[Table(name: 'device')] |
52
|
|
|
#[EntityListeners([LogListener::class])] |
53
|
|
|
#[Entity(repositoryClass: DeviceRepository::class)] |
54
|
|
|
class Device |
55
|
|
|
{ |
56
|
|
|
#[Groups(['device_config:read', 'device:read', 'spool_item:read', 'spool:read', 'spool:write', 'device:write'])] |
57
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
58
|
|
|
#[Column(name: 'id', type: 'integer', nullable: false)] |
59
|
|
|
#[Id] |
60
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
61
|
|
|
private int $id = 0; |
62
|
|
|
|
63
|
|
|
#[Groups(['device_config:read', 'device:read', 'spool_item:read', 'spool:read', 'spool:write', 'device:write'])] |
64
|
|
|
#[NotBlank] |
65
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['device' => 'exact'])] |
66
|
|
|
#[Column(name: 'device', type: 'string', length: 100, nullable: false)] |
67
|
|
|
private string $device = ''; |
68
|
|
|
|
69
|
|
|
#[Groups(['device_config:read', 'device:read', 'spool_item:read', 'spool:read', 'spool:write', 'device:write'])] |
70
|
|
|
#[NotBlank] |
71
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['alias' => 'exact'])] |
72
|
|
|
#[Column(name: 'alias', type: 'string', length: 100, nullable: true)] |
73
|
|
|
private string $alias = ''; |
74
|
|
|
|
75
|
|
|
public function getId(): int |
76
|
|
|
{ |
77
|
|
|
return $this->id; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getDevice(): string |
81
|
|
|
{ |
82
|
|
|
return $this->device; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function setDevice(string $device): self |
86
|
|
|
{ |
87
|
|
|
$this->device = $device; |
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get the value of alias |
93
|
|
|
*/ |
94
|
|
|
public function getAlias(): ?string |
95
|
|
|
{ |
96
|
|
|
return $this->alias; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Set the value of alias |
101
|
|
|
*/ |
102
|
|
|
public function setAlias(string | null $alias): self |
103
|
|
|
{ |
104
|
|
|
$this->alias = $alias; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
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