1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Content\Component\Hero; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Silverback\ApiComponentBundle\Entity\Content\Component\AbstractComponent; |
8
|
|
|
use Silverback\ApiComponentBundle\Entity\Content\Component\Navigation\Tabs\Tabs; |
9
|
|
|
use Silverback\ApiComponentBundle\Entity\Content\ComponentGroup; |
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 Hero |
16
|
|
|
* @package Silverback\ApiComponentBundle\Entity\Content\Component\Hero |
17
|
|
|
* @author Daniel West <[email protected]> |
18
|
|
|
* @ApiResource() |
19
|
|
|
* @ORM\Entity() |
20
|
|
|
*/ |
21
|
|
|
class Hero extends AbstractComponent |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @ORM\Column(type="string", nullable=false) |
25
|
|
|
* @Groups({"content", "component"}) |
26
|
|
|
* @var null|string |
27
|
|
|
*/ |
28
|
|
|
private $title; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @ORM\Column(type="string") |
32
|
|
|
* @Groups({"content", "component"}) |
33
|
|
|
* @var null|string |
34
|
|
|
*/ |
35
|
|
|
private $subtitle; |
36
|
|
|
|
37
|
3 |
|
public function __construct() |
38
|
|
|
{ |
39
|
3 |
|
parent::__construct(); |
40
|
3 |
|
$this->addValidComponent(Tabs::class); |
41
|
3 |
|
$this->addComponentGroup(new ComponentGroup()); |
42
|
3 |
|
} |
43
|
|
|
|
44
|
5 |
|
public static function loadValidatorMetadata(ClassMetadata $metadata) |
45
|
|
|
{ |
46
|
5 |
|
$metadata->addPropertyConstraint( |
47
|
5 |
|
'title', |
48
|
5 |
|
new Assert\NotNull() |
49
|
|
|
); |
50
|
5 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return null|string |
54
|
|
|
*/ |
55
|
1 |
|
public function getTitle(): ?string |
56
|
|
|
{ |
57
|
1 |
|
return $this->title; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param null|string $title |
62
|
|
|
*/ |
63
|
2 |
|
public function setTitle(?string $title): void |
64
|
|
|
{ |
65
|
2 |
|
$this->title = $title; |
66
|
2 |
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return null|string |
70
|
|
|
*/ |
71
|
1 |
|
public function getSubtitle(): ?string |
72
|
|
|
{ |
73
|
1 |
|
return $this->subtitle; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param null|string $subtitle |
78
|
|
|
*/ |
79
|
2 |
|
public function setSubtitle(?string $subtitle): void |
80
|
|
|
{ |
81
|
2 |
|
$this->subtitle = $subtitle; |
82
|
2 |
|
} |
83
|
|
|
|
84
|
|
|
public function __toString() |
85
|
|
|
{ |
86
|
|
|
return 'Hero: ' . $this->getTitle(); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|