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