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