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