1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace JoppeDc\SyliusBetterSeoPlugin\Entity; |
6
|
|
|
|
7
|
|
|
use Sylius\Component\Resource\Model\ResourceInterface; |
8
|
|
|
use Sylius\Component\Resource\Model\TranslatableInterface; |
9
|
|
|
use Sylius\Component\Resource\Model\TranslatableTrait; |
10
|
|
|
use Sylius\Component\Resource\Model\TranslationInterface; |
11
|
|
|
|
12
|
|
|
class Seo implements TranslatableInterface, ResourceInterface |
13
|
|
|
{ |
14
|
|
|
use TranslatableTrait { |
15
|
|
|
__construct as private initializeTranslationsCollection; |
16
|
|
|
getTranslation as private doGetTranslation; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var int|null |
21
|
|
|
*/ |
22
|
|
|
protected $id; |
23
|
|
|
|
24
|
|
|
public function __construct() |
25
|
|
|
{ |
26
|
|
|
$this->initializeTranslationsCollection(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function __toString() |
30
|
|
|
{ |
31
|
|
|
return (string) $this->getId(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getPageTitle(): ?string |
35
|
|
|
{ |
36
|
|
|
return $this->getTranslation()->getPageTitle(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function setPageTitle(?string $pageTitle): void |
40
|
|
|
{ |
41
|
|
|
$this->getTranslation()->setPageTitle($pageTitle); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getOgTitle(): ?string |
45
|
|
|
{ |
46
|
|
|
return $this->getTranslation()->getOgTitle(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function setOgTitle(?string $ogTitle): void |
50
|
|
|
{ |
51
|
|
|
$this->getTranslation()->setOgTitle($ogTitle); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getOgDescription(): ?string |
55
|
|
|
{ |
56
|
|
|
return $this->getTranslation()->getOgDescription(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function setOgDescription(?string $ogDescription): void |
60
|
|
|
{ |
61
|
|
|
$this->getTranslation()->setOgDescription($ogDescription); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function getTwitterTitle(): ?string |
65
|
|
|
{ |
66
|
|
|
return $this->getTranslation()->getTwitterTitle(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function setTwitterTitle(?string $twitterTitle): void |
70
|
|
|
{ |
71
|
|
|
$this->getTranslation()->setTwitterTitle($twitterTitle); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getTwitterDescription(): ?string |
75
|
|
|
{ |
76
|
|
|
return $this->getTranslation()->getTwitterDescription(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function setTwitterDescription(?string $twitterDescription): void |
80
|
|
|
{ |
81
|
|
|
$this->getTranslation()->setTwitterDescription($twitterDescription); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getTwitterSite(): ?string |
85
|
|
|
{ |
86
|
|
|
return $this->getTranslation()->getTwitterSite(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function setTwitterSite(?string $twitterSite): void |
90
|
|
|
{ |
91
|
|
|
$this->getTranslation()->setTwitterSite($twitterSite); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getExtraTags(): ?string |
95
|
|
|
{ |
96
|
|
|
return $this->getTranslation()->getExtraTags(); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function setExtraTags(?string $extraTags): void |
100
|
|
|
{ |
101
|
|
|
$this->getTranslation()->setExtraTags($extraTags); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getId() |
105
|
|
|
{ |
106
|
|
|
return $this->id; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function setId(?int $id): void |
110
|
|
|
{ |
111
|
|
|
$this->id = $id; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function getImage(): ?SeoImage |
115
|
|
|
{ |
116
|
|
|
return $this->getTranslation()->getImage(); |
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return SeoTranslation |
121
|
|
|
*/ |
122
|
|
|
public function getTranslation(?string $locale = null): TranslationInterface |
123
|
|
|
{ |
124
|
|
|
/** @var SeoTranslation $translation */ |
125
|
|
|
$translation = $this->doGetTranslation($locale); |
126
|
|
|
|
127
|
|
|
return $translation; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
protected function createTranslation(): SeoTranslation |
131
|
|
|
{ |
132
|
|
|
return new SeoTranslation(); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|