|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Component\Feature; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
8
|
|
|
use Silverback\ApiComponentBundle\Entity\Component\AbstractComponent; |
|
9
|
|
|
use Silverback\ApiComponentBundle\Entity\Route\Route; |
|
10
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
11
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
12
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class AbstractFeatureItem |
|
16
|
|
|
* @package Silverback\ApiComponentBundle\Entity\Component\Feature |
|
17
|
|
|
*/ |
|
18
|
|
|
abstract class AbstractFeatureItem extends AbstractComponent implements FeatureItemInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @ORM\Column() |
|
22
|
|
|
* @Groups({"component", "content"}) |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $title; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @ORM\Column() |
|
29
|
|
|
* @Groups({"component", "content"}) |
|
30
|
|
|
* @var string|null |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $url; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Route\Route") |
|
36
|
|
|
* @ORM\JoinColumn(referencedColumnName="route") |
|
37
|
|
|
* @Groups({"component", "content"}) |
|
38
|
|
|
* @var Route|null |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $route; |
|
41
|
|
|
|
|
42
|
2 |
|
public static function loadValidatorMetadata(ClassMetadata $metadata) |
|
43
|
|
|
{ |
|
44
|
2 |
|
$metadata->addPropertyConstraint( |
|
45
|
2 |
|
'title', |
|
46
|
2 |
|
new Assert\NotBlank() |
|
47
|
|
|
); |
|
48
|
2 |
|
$metadata->addPropertyConstraint( |
|
49
|
2 |
|
'url', |
|
50
|
2 |
|
new Assert\Url() |
|
51
|
|
|
); |
|
52
|
2 |
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getTitle(): string |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->title; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param string $title |
|
64
|
|
|
*/ |
|
65
|
|
|
public function setTitle(string $title): void |
|
66
|
|
|
{ |
|
67
|
|
|
$this->title = $title; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return null|string |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getUrl(): ?string |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->url; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @param null|string $url |
|
80
|
|
|
*/ |
|
81
|
|
|
public function setUrl(?string $url): void |
|
82
|
|
|
{ |
|
83
|
|
|
$this->url = $url; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return null|Route |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getRoute(): ?Route |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->route; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @param null|Route $route |
|
96
|
|
|
*/ |
|
97
|
|
|
public function setRoute(?Route $route): void |
|
98
|
|
|
{ |
|
99
|
|
|
$this->route = $route; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|