1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
6
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
8
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
10
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
11
|
|
|
use ControleOnline\Controller\GetThemeColorsAction; |
12
|
|
|
use ControleOnline\Listener\LogListener; |
13
|
|
|
use ControleOnline\Repository\ThemeRepository; |
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
15
|
|
|
use Symfony\Component\Serializer\Attribute\Groups; |
|
|
|
|
16
|
|
|
|
17
|
|
|
#[ApiResource( |
18
|
|
|
operations: [ |
19
|
|
|
new Get(security: 'is_granted(\'ROLE_CLIENT\')'), |
20
|
|
|
new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'), |
21
|
|
|
new GetCollection( |
22
|
|
|
security: 'is_granted(\'PUBLIC_ACCESS\')', |
23
|
|
|
uriTemplate: '/themes-colors.css', |
24
|
|
|
controller: GetThemeColorsAction::class |
25
|
|
|
), |
26
|
|
|
], |
27
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv'], 'css' => ['text/css']], |
28
|
|
|
normalizationContext: ['groups' => ['theme:read']], |
29
|
|
|
denormalizationContext: ['groups' => ['theme:write']] |
30
|
|
|
)] |
31
|
|
|
#[ApiFilter(filterClass: OrderFilter::class, properties: ['theme' => 'ASC'])] |
32
|
|
|
#[ApiFilter( |
33
|
|
|
filterClass: SearchFilter::class, |
34
|
|
|
properties: [ |
35
|
|
|
'theme' => 'partial', |
36
|
|
|
'state.uf' => 'exact' |
37
|
|
|
] |
38
|
|
|
)] |
39
|
|
|
#[ORM\Table(name: 'theme')] |
40
|
|
|
#[ORM\EntityListeners([LogListener::class])] |
41
|
|
|
#[ORM\Entity(repositoryClass: ThemeRepository::class)] |
42
|
|
|
class Theme |
43
|
|
|
{ |
44
|
|
|
#[ORM\Column(name: 'id', type: 'integer', nullable: false)] |
45
|
|
|
#[ORM\Id] |
46
|
|
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')] |
47
|
|
|
#[Groups(['theme:read'])] |
48
|
|
|
private int $id; |
49
|
|
|
|
50
|
|
|
#[ORM\Column(name: 'theme', type: 'string', length: 80, nullable: false)] |
51
|
|
|
#[Groups(['theme:read'])] |
52
|
|
|
private string $theme; |
53
|
|
|
|
54
|
|
|
#[ORM\Column(name: 'background', type: 'integer', nullable: true)] |
55
|
|
|
#[Groups(['theme:read'])] |
56
|
|
|
private ?int $background = null; |
57
|
|
|
|
58
|
|
|
#[ORM\Column(name: 'colors', type: 'json', nullable: false)] |
59
|
|
|
#[Groups(['theme:read'])] |
60
|
|
|
private array $colors; |
61
|
|
|
|
62
|
|
|
public function getId(): int |
63
|
|
|
{ |
64
|
|
|
return $this->id; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function setTheme(string $theme): self |
68
|
|
|
{ |
69
|
|
|
$this->theme = $theme; |
70
|
|
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getTheme(): string |
74
|
|
|
{ |
75
|
|
|
return strtoupper($this->theme); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getBackground(): ?int |
79
|
|
|
{ |
80
|
|
|
return $this->background; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function setBackground(?int $background): self |
84
|
|
|
{ |
85
|
|
|
$this->background = $background; |
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function getColors(bool $decode = false): mixed |
90
|
|
|
{ |
91
|
|
|
return $decode ? (object) json_decode(json_encode($this->colors)) : $this->colors; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function setColors(array $colors): self |
95
|
|
|
{ |
96
|
|
|
$this->colors = $colors; |
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function addColors(string $key, mixed $value): self |
101
|
|
|
{ |
102
|
|
|
$colors = $this->getColors(true); |
103
|
|
|
$colors->$key = $value; |
104
|
|
|
$this->colors = (array) $colors; |
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
} |
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