|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace JoppeDc\SyliusBetterSeoPlugin\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
8
|
|
|
use Doctrine\Common\Collections\Collection; |
|
9
|
|
|
use Sylius\Component\Core\Model\ImageInterface; |
|
10
|
|
|
use Sylius\Component\Core\Model\ImagesAwareInterface; |
|
11
|
|
|
use Sylius\Component\Resource\Model\AbstractTranslation; |
|
12
|
|
|
use Sylius\Component\Resource\Model\ResourceInterface; |
|
13
|
|
|
|
|
14
|
|
|
class ProductSeoTranslation extends AbstractTranslation implements ResourceInterface, ImagesAwareInterface { |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var Collection|ImageInterface[] |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $images; |
|
20
|
|
|
|
|
21
|
|
|
public function __construct() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->images = new ArrayCollection(); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var int|null |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $id; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string|null |
|
33
|
|
|
*/ |
|
34
|
|
|
private $pageTitle; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var string|null |
|
38
|
|
|
*/ |
|
39
|
|
|
private $ogTitle; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var string|null |
|
43
|
|
|
*/ |
|
44
|
|
|
private $ogDescription; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var string|null |
|
48
|
|
|
*/ |
|
49
|
|
|
private $twitterTitle; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var string|null |
|
53
|
|
|
*/ |
|
54
|
|
|
private $twitterDescription; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var string|null |
|
58
|
|
|
*/ |
|
59
|
|
|
private $twitterSite; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var string|null |
|
63
|
|
|
*/ |
|
64
|
|
|
private $extraTags; |
|
65
|
|
|
|
|
66
|
|
|
public function getId(): ?int |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->id; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function setId(?int $id): void |
|
72
|
|
|
{ |
|
73
|
|
|
$this->id = $id; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function getPageTitle(): ?string |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->pageTitle; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function setPageTitle(?string $pageTitle): void |
|
82
|
|
|
{ |
|
83
|
|
|
$this->pageTitle = $pageTitle; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function getOgTitle(): ?string |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->ogTitle; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function setOgTitle(?string $ogTitle): void |
|
92
|
|
|
{ |
|
93
|
|
|
$this->ogTitle = $ogTitle; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function getOgDescription(): ?string |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->ogDescription; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function setOgDescription(?string $ogDescription): void |
|
102
|
|
|
{ |
|
103
|
|
|
$this->ogDescription = $ogDescription; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function getTwitterTitle(): ?string |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->twitterTitle; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
public function setTwitterTitle(?string $twitterTitle): void |
|
112
|
|
|
{ |
|
113
|
|
|
$this->twitterTitle = $twitterTitle; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function getTwitterDescription(): ?string |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->twitterDescription; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function setTwitterDescription(?string $twitterDescription): void |
|
122
|
|
|
{ |
|
123
|
|
|
$this->twitterDescription = $twitterDescription; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function getTwitterSite(): ?string |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->twitterSite; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function setTwitterSite(?string $twitterSite): void |
|
132
|
|
|
{ |
|
133
|
|
|
$this->twitterSite = $twitterSite; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function getExtraTags(): ?string |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->extraTags; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function setExtraTags(?string $extraTags): void |
|
142
|
|
|
{ |
|
143
|
|
|
$this->extraTags = $extraTags; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* {@inheritdoc} |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getImages(): Collection |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->images; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* {@inheritdoc} |
|
156
|
|
|
*/ |
|
157
|
|
|
public function getImagesByType(string $type): Collection |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->images->filter(function (ImageInterface $image) use ($type) { |
|
160
|
|
|
return $type === $image->getType(); |
|
161
|
|
|
}); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* {@inheritdoc} |
|
166
|
|
|
*/ |
|
167
|
|
|
public function hasImages(): bool |
|
168
|
|
|
{ |
|
169
|
|
|
return !$this->images->isEmpty(); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* {@inheritdoc} |
|
174
|
|
|
*/ |
|
175
|
|
|
public function hasImage(ImageInterface $image): bool |
|
176
|
|
|
{ |
|
177
|
|
|
return $this->images->contains($image); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* {@inheritdoc} |
|
182
|
|
|
*/ |
|
183
|
|
|
public function addImage(ImageInterface $image): void |
|
184
|
|
|
{ |
|
185
|
|
|
$image->setOwner($this); |
|
186
|
|
|
$this->images->add($image); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* {@inheritdoc} |
|
191
|
|
|
*/ |
|
192
|
|
|
public function removeImage(ImageInterface $image): void |
|
193
|
|
|
{ |
|
194
|
|
|
if ($this->hasImage($image)) { |
|
195
|
|
|
$image->setOwner(null); |
|
196
|
|
|
$this->images->removeElement($image); |
|
197
|
|
|
} |
|
198
|
|
|
} |
|
199
|
|
|
} |
|
200
|
|
|
|