ControleOnline /
api-platform-common
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ControleOnline\Entity; |
||
| 4 | |||
| 5 | use Symfony\Component\Serializer\Attribute\Groups; |
||
|
0 ignored issues
–
show
|
|||
| 6 | |||
| 7 | use ControleOnline\Repository\DeviceConfigRepository; |
||
| 8 | use ControleOnline\Listener\LogListener; |
||
| 9 | use ApiPlatform\Metadata\ApiResource; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 10 | use ApiPlatform\Metadata\ApiFilter; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\ApiFilter was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 11 | use ApiPlatform\Metadata\Delete; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\Delete was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 12 | use ApiPlatform\Metadata\Get; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\Get was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 13 | use ApiPlatform\Metadata\GetCollection; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\GetCollection was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 14 | use ApiPlatform\Metadata\Post; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\Post was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | use ApiPlatform\Metadata\Put; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Metadata\Put was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 16 | use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Doctrine\Orm\Filter\OrderFilter was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 17 | use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
||
|
0 ignored issues
–
show
The type
ApiPlatform\Doctrine\Orm\Filter\SearchFilter was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 18 | use ControleOnline\Controller\AddDeviceConfigAction; |
||
| 19 | use Doctrine\ORM\Mapping\Column; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping\Column was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 20 | use Doctrine\ORM\Mapping\Entity; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping\Entity was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 21 | use Doctrine\ORM\Mapping\EntityListeners; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping\EntityListeners was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 22 | use Doctrine\ORM\Mapping\GeneratedValue; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping\GeneratedValue was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 23 | use Doctrine\ORM\Mapping\Id; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping\Id was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 24 | use Doctrine\ORM\Mapping\JoinColumn; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping\JoinColumn was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 25 | use Doctrine\ORM\Mapping\ManyToOne; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping\ManyToOne was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 26 | use Doctrine\ORM\Mapping\Table; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\Mapping\Table was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 27 | use stdClass; |
||
| 28 | use Symfony\Component\Validator\Constraints\NotBlank; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Validator\Constraints\NotBlank was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 29 | |||
| 30 | #[ApiResource( |
||
| 31 | operations: [ |
||
| 32 | new Get(security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')'), |
||
| 33 | new Put( |
||
| 34 | security: 'is_granted(\'ROLE_CLIENT\')', |
||
| 35 | denormalizationContext: ['groups' => ['device_config:write']] |
||
| 36 | ), |
||
| 37 | new Post( |
||
| 38 | security: 'is_granted(\'ROLE_CLIENT\')', |
||
| 39 | uriTemplate: '/device_configs/add-configs', |
||
| 40 | controller: AddDeviceConfigAction::class |
||
| 41 | ), |
||
| 42 | new Delete(security: 'is_granted(\'ROLE_CLIENT\')'), |
||
| 43 | new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'), |
||
| 44 | new GetCollection( |
||
| 45 | security: 'is_granted(\'PUBLIC_ACCESS\')', |
||
| 46 | ) |
||
| 47 | ], |
||
| 48 | formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
||
| 49 | normalizationContext: ['groups' => ['device_config:read']], |
||
| 50 | denormalizationContext: ['groups' => ['device_config:write']] |
||
| 51 | )] |
||
| 52 | #[ApiFilter(filterClass: OrderFilter::class, properties: ['id' => 'ASC'])] |
||
| 53 | #[Table(name: 'device_configs')] |
||
| 54 | #[EntityListeners([LogListener::class])] |
||
| 55 | #[Entity(repositoryClass: DeviceConfigRepository::class)] |
||
| 56 | class DeviceConfig |
||
| 57 | { |
||
| 58 | #[Groups(['device_config:read', 'device:read', 'device_config:write'])] |
||
| 59 | #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
||
| 60 | #[Column(name: 'id', type: 'integer', nullable: false)] |
||
| 61 | #[Id] |
||
| 62 | #[GeneratedValue(strategy: 'IDENTITY')] |
||
| 63 | private int $id = 0; |
||
| 64 | |||
| 65 | #[Groups(['device_config:read', 'device:read', 'device_config:write'])] |
||
| 66 | #[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])] |
||
| 67 | #[JoinColumn(name: 'people_id', referencedColumnName: 'id', nullable: false)] |
||
| 68 | #[ManyToOne(targetEntity: People::class)] |
||
| 69 | private People $people; |
||
|
0 ignored issues
–
show
The type
ControleOnline\Entity\People was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 70 | |||
| 71 | #[Groups(['device_config:read', 'device:read', 'device_config:write'])] |
||
| 72 | #[ApiFilter(filterClass: SearchFilter::class, properties: ['device' => 'exact'])] |
||
| 73 | #[ApiFilter(filterClass: SearchFilter::class, properties: ['device.device' => 'exact'])] |
||
| 74 | #[JoinColumn(name: 'device_id', referencedColumnName: 'id', nullable: false)] |
||
| 75 | #[ManyToOne(targetEntity: Device::class)] |
||
| 76 | private Device $device; |
||
| 77 | |||
| 78 | #[Groups(['device_config:read', 'device:read', 'device_config:write'])] |
||
| 79 | #[NotBlank] |
||
| 80 | #[ApiFilter(filterClass: SearchFilter::class, properties: ['configs' => 'exact'])] |
||
| 81 | #[Column(name: 'configs', type: 'string', length: 100, nullable: false)] |
||
| 82 | private string $configs; |
||
| 83 | |||
| 84 | public function __construct() |
||
| 85 | { |
||
| 86 | $this->configs = json_encode(new stdClass()); |
||
| 87 | } |
||
| 88 | |||
| 89 | public function getId(): int |
||
| 90 | { |
||
| 91 | return $this->id; |
||
| 92 | } |
||
| 93 | |||
| 94 | public function getPeople(): People |
||
| 95 | { |
||
| 96 | return $this->people; |
||
| 97 | } |
||
| 98 | |||
| 99 | public function setPeople(People $people): self |
||
| 100 | { |
||
| 101 | $this->people = $people; |
||
| 102 | return $this; |
||
| 103 | } |
||
| 104 | |||
| 105 | public function getConfigs(bool $decode = false): string|array |
||
| 106 | { |
||
| 107 | // Ensure we're decoding a string, even if it was temporarily an array internally |
||
| 108 | $configString = is_array($this->configs) ? json_encode($this->configs) : $this->configs; |
||
|
0 ignored issues
–
show
|
|||
| 109 | return $decode ? json_decode((string) $configString, true) : (string) $configString; |
||
| 110 | } |
||
| 111 | |||
| 112 | public function addConfig(string $key, mixed $value): self |
||
| 113 | { |
||
| 114 | $configs = $this->getConfigs(true); |
||
| 115 | $configs[$key] = $value; |
||
| 116 | return $this->setConfigs($configs); |
||
| 117 | } |
||
| 118 | |||
| 119 | public function setConfigs(string|array|object $configs): self |
||
| 120 | { |
||
| 121 | if (is_string($configs)) |
||
|
0 ignored issues
–
show
|
|||
| 122 | $configs = json_decode($configs, true); |
||
| 123 | |||
| 124 | $this->configs = json_encode($configs); |
||
| 125 | return $this; |
||
| 126 | } |
||
| 127 | |||
| 128 | public function getDevice(): Device |
||
| 129 | { |
||
| 130 | return $this->device; |
||
| 131 | } |
||
| 132 | |||
| 133 | public function setDevice(Device $device): self |
||
| 134 | { |
||
| 135 | $this->device = $device; |
||
| 136 | return $this; |
||
| 137 | } |
||
| 138 | } |
||
| 139 |
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