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