1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Component\Feature; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Silverback\ApiComponentBundle\Entity\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\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
|
|
|
protected $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
|
|
|
public static function loadValidatorMetadata(ClassMetadata $metadata) |
41
|
|
|
{ |
42
|
|
|
$metadata->addPropertyConstraint( |
43
|
|
|
'title', |
44
|
|
|
new Assert\NotBlank() |
45
|
|
|
); |
46
|
|
|
$metadata->addPropertyConstraint( |
47
|
|
|
'url', |
48
|
|
|
new Assert\Url() |
49
|
|
|
); |
50
|
|
|
} |
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
|
|
|
public function setTitle(string $title): void |
64
|
|
|
{ |
65
|
|
|
$this->title = $title; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return null|string |
70
|
|
|
*/ |
71
|
|
|
public function getUrl(): ?string |
72
|
|
|
{ |
73
|
|
|
return $this->url; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param null|string $url |
78
|
|
|
*/ |
79
|
|
|
public function setUrl(?string $url): void |
80
|
|
|
{ |
81
|
|
|
$this->url = $url; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return null|Route |
86
|
|
|
*/ |
87
|
|
|
public function getRoute(): ?Route |
88
|
|
|
{ |
89
|
|
|
return $this->route; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param null|Route $route |
94
|
|
|
*/ |
95
|
|
|
public function setRoute(?Route $route): void |
96
|
|
|
{ |
97
|
|
|
$this->route = $route; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|