1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
6
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\Delete; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
11
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
|
|
|
|
12
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
13
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter; |
|
|
|
|
14
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
15
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
16
|
|
|
use ControleOnline\Controller\AddDeviceConfigAction; |
17
|
|
|
use ControleOnline\Filter\CustomOrFilter; |
18
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
19
|
|
|
use stdClass; |
20
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
|
21
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class}) |
25
|
|
|
* @ORM\Table (name="device") |
26
|
|
|
* @ORM\Entity (repositoryClass="ControleOnline\Repository\DeviceRepository") |
27
|
|
|
*/ |
28
|
|
|
#[ApiResource( |
29
|
|
|
operations: [ |
30
|
|
|
new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'), |
31
|
|
|
new Put( |
32
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
33
|
|
|
denormalizationContext: ['groups' => ['device_config:write']] |
34
|
|
|
), |
35
|
|
|
new Post( |
36
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
37
|
|
|
uriTemplate: '/devices/add-configs', |
38
|
|
|
controller: AddDeviceConfigAction::class |
39
|
|
|
), |
40
|
|
|
new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
41
|
|
|
new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
42
|
|
|
new GetCollection( |
43
|
|
|
security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')', |
44
|
|
|
) |
45
|
|
|
], |
46
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
47
|
|
|
normalizationContext: ['groups' => ['device_config:read']], |
48
|
|
|
denormalizationContext: ['groups' => ['device_config:write']] |
49
|
|
|
)] |
50
|
|
|
#[ApiFilter(filterClass: OrderFilter::class, properties: ['id' => 'ASC'])] |
51
|
|
|
|
52
|
|
|
class DeviceConfig |
53
|
|
|
{ |
54
|
|
|
/** |
55
|
|
|
* @var integer |
56
|
|
|
* |
57
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
58
|
|
|
* @ORM\Id |
59
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
60
|
|
|
* @Groups({"device_config:read","device:read","device_config:write"}) |
61
|
|
|
*/ |
62
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
63
|
|
|
|
64
|
|
|
private $id; |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var \ControleOnline\Entity\People |
|
|
|
|
69
|
|
|
* |
70
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
71
|
|
|
* @ORM\JoinColumns({ |
72
|
|
|
* @ORM\JoinColumn(name="people_id", referencedColumnName="id") |
73
|
|
|
* }) |
74
|
|
|
* @Groups({"device_config:read","device:read","device_config:write"}) |
75
|
|
|
*/ |
76
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])] |
77
|
|
|
|
78
|
|
|
private $people; |
79
|
|
|
/** |
80
|
|
|
* @var \ControleOnline\Entity\Device |
81
|
|
|
* |
82
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Device") |
83
|
|
|
* @ORM\JoinColumns({ |
84
|
|
|
* @ORM\JoinColumn(name="device_id", referencedColumnName="id") |
85
|
|
|
* }) |
86
|
|
|
* @Groups({"device_config:read","device:read","device_config:write"}) |
87
|
|
|
*/ |
88
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['device' => 'exact'])] |
89
|
|
|
|
90
|
|
|
private $device; |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @var string |
95
|
|
|
* |
96
|
|
|
* @ORM\Column(name="configs", type="string", length=100, nullable=false) |
97
|
|
|
* @Groups({"device_config:read","device:read","device_config:write"}) |
98
|
|
|
* @Assert\NotBlank |
99
|
|
|
*/ |
100
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['configs' => 'exact'])] |
101
|
|
|
|
102
|
|
|
private $configs; |
103
|
|
|
public function __construct() |
104
|
|
|
{ |
105
|
|
|
$this->configs = json_encode(new stdClass()); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Get the value of id |
110
|
|
|
*/ |
111
|
|
|
public function getId() |
112
|
|
|
{ |
113
|
|
|
return $this->id; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get the value of people |
118
|
|
|
*/ |
119
|
|
|
public function getPeople() |
120
|
|
|
{ |
121
|
|
|
return $this->people; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Set the value of people |
126
|
|
|
*/ |
127
|
|
|
public function setPeople($people): self |
128
|
|
|
{ |
129
|
|
|
$this->people = $people; |
130
|
|
|
|
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
|
136
|
|
|
|
137
|
|
|
|
138
|
|
|
public function getConfigs($decode = false) |
139
|
|
|
{ |
140
|
|
|
return $decode ? json_decode((is_array($this->configs) ? json_encode($this->configs) : $this->configs), true) : $this->configs; |
|
|
|
|
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
|
144
|
|
|
public function addConfigs($key, $value) |
145
|
|
|
{ |
146
|
|
|
$configs = $this->getConfigs(true); |
147
|
|
|
$configs[$key] = $value; |
148
|
|
|
$this->configs = json_encode($configs); |
149
|
|
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
|
153
|
|
|
public function setConfigs($configs) |
154
|
|
|
{ |
155
|
|
|
$this->configs = json_encode($configs); |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Get the value of device |
161
|
|
|
*/ |
162
|
|
|
public function getDevice() |
163
|
|
|
{ |
164
|
|
|
return $this->device; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Set the value of device |
169
|
|
|
*/ |
170
|
|
|
public function setDevice($device): self |
171
|
|
|
{ |
172
|
|
|
$this->device = $device; |
173
|
|
|
|
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
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