|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace ProjetNormandie\PageBundle\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
8
|
|
|
use ApiPlatform\Metadata\Get; |
|
9
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
10
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
11
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
12
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
13
|
|
|
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface; |
|
14
|
|
|
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait; |
|
15
|
|
|
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface; |
|
16
|
|
|
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableMethodsTrait; |
|
17
|
|
|
use Knp\DoctrineBehaviors\Model\Translatable\TranslatablePropertiesTrait; |
|
18
|
|
|
use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface; |
|
19
|
|
|
use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait; |
|
20
|
|
|
use ProjetNormandie\PageBundle\Repository\PageRepository; |
|
21
|
|
|
use ProjetNormandie\PageBundle\ValueObject\PageStatus; |
|
|
|
|
|
|
22
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
23
|
|
|
|
|
24
|
|
|
#[ORM\Table(name:'pnp_page')] |
|
25
|
|
|
#[ORM\Entity(repositoryClass: PageRepository::class)] |
|
26
|
|
|
#[ApiResource( |
|
27
|
|
|
operations: [ |
|
28
|
|
|
new GetCollection(), |
|
29
|
|
|
new Get(), |
|
30
|
|
|
], |
|
31
|
|
|
normalizationContext: ['groups' => ['page:read']] |
|
32
|
|
|
)] |
|
33
|
|
|
#[ApiFilter(SearchFilter::class, properties: ['slug' => 'exact'])] |
|
34
|
|
|
|
|
35
|
|
|
class Page implements TimestampableInterface, TranslatableInterface, SluggableInterface |
|
36
|
|
|
{ |
|
37
|
|
|
use TimestampableTrait; |
|
38
|
|
|
use TranslatablePropertiesTrait; |
|
39
|
|
|
use TranslatableMethodsTrait; |
|
40
|
|
|
use SluggableTrait; |
|
41
|
|
|
|
|
42
|
|
|
#[Groups(['page:read'])] |
|
43
|
|
|
#[ORM\Id, ORM\Column, ORM\GeneratedValue] |
|
44
|
|
|
private ?int $id = null; |
|
45
|
|
|
|
|
46
|
|
|
#[Groups(['user:read'])] |
|
47
|
|
|
#[ORM\Column(length: 255, nullable: false)] |
|
48
|
|
|
private string $name = ''; |
|
49
|
|
|
|
|
50
|
|
|
#[ORM\Column(length: 255, nullable: false)] |
|
51
|
|
|
private string $status = PageStatus::PUBLIC; |
|
52
|
|
|
|
|
53
|
|
|
#[ORM\Column(length: 255, nullable: false, options: ['default' => true])] |
|
54
|
|
|
private bool $enabled = true; |
|
55
|
|
|
|
|
56
|
|
|
public function __toString() |
|
57
|
|
|
{ |
|
58
|
|
|
return sprintf('%s [%s]', $this->getName(), $this->id); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getDefaultText(): string |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->translate('en', false)->getText(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function setId(int $id): void |
|
67
|
|
|
{ |
|
68
|
|
|
$this->id = $id; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function getId(): ?int |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->id; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function setName(string $name): void |
|
77
|
|
|
{ |
|
78
|
|
|
$this->name = $name; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function getName(): string |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->name; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function setStatus(string $status): void |
|
87
|
|
|
{ |
|
88
|
|
|
$value = new PageStatus($status); |
|
89
|
|
|
$this->status = $value->getValue(); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function getStatus(): string |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->status; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getPageStatus(): PageStatus |
|
98
|
|
|
{ |
|
99
|
|
|
return new PageStatus($this->status); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function setEnabled(bool $enabled): void |
|
103
|
|
|
{ |
|
104
|
|
|
$this->enabled = $enabled; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function getEnabled(): bool |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->enabled; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function setTitle(string $title): void |
|
113
|
|
|
{ |
|
114
|
|
|
$this->translate(null, false)->setText($title); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
#[Groups(['page:read'])] |
|
118
|
|
|
public function getTitle(): string |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->translate(null, false)->getTitle(); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function setText(string $text): void |
|
124
|
|
|
{ |
|
125
|
|
|
$this->translate(null, false)->setText($text); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
#[Groups(['page:read'])] |
|
129
|
|
|
public function getText(): string |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->translate(null, false)->getText(); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getSluggableFields(): array |
|
135
|
|
|
{ |
|
136
|
|
|
return ['name']; |
|
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