1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\SeoBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManager; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Kunstmaan\AdminBundle\Entity\AbstractEntity; |
8
|
|
|
use Kunstmaan\MediaBundle\Entity\Media; |
9
|
|
|
use Kunstmaan\SeoBundle\Form\SeoType; |
10
|
|
|
use Kunstmaan\UtilitiesBundle\Helper\ClassLookup; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Seo metadata for entities |
14
|
|
|
* |
15
|
|
|
* @ORM\Entity(repositoryClass="Kunstmaan\SeoBundle\Repository\SeoRepository") |
16
|
|
|
* @ORM\Table(name="kuma_seo", indexes={@ORM\Index(name="idx_seo_lookup", columns={"ref_id", "ref_entity_name"})}) |
17
|
|
|
* @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT") |
18
|
|
|
*/ |
19
|
|
|
class Seo extends AbstractEntity |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
* |
24
|
|
|
* @ORM\Column(name="meta_title", type="string", nullable=true) |
25
|
|
|
*/ |
26
|
|
|
protected $metaTitle; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
* |
31
|
|
|
* @ORM\Column(name="meta_description", type="text", nullable=true) |
32
|
|
|
*/ |
33
|
|
|
protected $metaDescription; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
* |
38
|
|
|
* @ORM\Column(name="meta_author", type="string", nullable=true) |
39
|
|
|
*/ |
40
|
|
|
protected $metaAuthor; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
* |
45
|
|
|
* @ORM\Column(name="meta_robots", type="string", nullable=true) |
46
|
|
|
*/ |
47
|
|
|
protected $metaRobots; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
* |
52
|
|
|
* @ORM\Column(name="og_type", type="string", nullable=true) |
53
|
|
|
*/ |
54
|
|
|
protected $ogType; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
* |
59
|
|
|
* @ORM\Column(name="og_title", type="string", nullable=true) |
60
|
|
|
*/ |
61
|
|
|
protected $ogTitle; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var string |
65
|
|
|
* |
66
|
|
|
* @ORM\Column(name="og_description", type="text", nullable=true) |
67
|
|
|
*/ |
68
|
|
|
protected $ogDescription; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var Media |
72
|
|
|
* |
73
|
|
|
* @ORM\ManyToOne(targetEntity="Kunstmaan\MediaBundle\Entity\Media") |
74
|
|
|
* @ORM\JoinColumn(name="og_image_id", referencedColumnName="id") |
75
|
|
|
*/ |
76
|
|
|
protected $ogImage; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var string |
80
|
|
|
* |
81
|
|
|
* @ORM\Column(name="extra_metadata", type="text", nullable=true) |
82
|
|
|
*/ |
83
|
|
|
protected $extraMetadata; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var int |
87
|
|
|
* |
88
|
|
|
* @ORM\Column(type="bigint", name="ref_id") |
89
|
|
|
*/ |
90
|
|
|
protected $refId; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @var string |
94
|
|
|
* |
95
|
|
|
* @ORM\Column(type="string", name="ref_entity_name") |
96
|
|
|
*/ |
97
|
|
|
protected $refEntityName; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @ORM\Column(type="string", nullable=true, name="og_url") |
101
|
|
|
*/ |
102
|
|
|
protected $ogUrl; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @ORM\Column(type="string", length=100, nullable=true, name="og_article_author") |
106
|
|
|
*/ |
107
|
|
|
protected $ogArticleAuthor; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @ORM\Column(type="string", length=100, nullable=true, name="og_article_publisher") |
111
|
|
|
*/ |
112
|
|
|
protected $ogArticlePublisher; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @ORM\Column(type="string", length=100, nullable=true, name="og_article_section") |
116
|
|
|
*/ |
117
|
|
|
protected $ogArticleSection; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @var string |
121
|
|
|
* |
122
|
|
|
* @ORM\Column(name="twitter_title", type="string", length=255, nullable=true) |
123
|
|
|
*/ |
124
|
|
|
protected $twitterTitle; |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @var string |
128
|
|
|
* |
129
|
|
|
* @ORM\Column(name="twitter_description", type="text", nullable=true) |
130
|
|
|
*/ |
131
|
|
|
protected $twitterDescription; |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @var string |
135
|
|
|
* |
136
|
|
|
* @ORM\Column(name="twitter_site", type="string", length=255, nullable=true) |
137
|
|
|
*/ |
138
|
|
|
protected $twitterSite; |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @var string |
142
|
|
|
* |
143
|
|
|
* @ORM\Column(name="twitter_creator", type="string", length=255, nullable=true) |
144
|
|
|
*/ |
145
|
|
|
protected $twitterCreator; |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @var Media |
149
|
|
|
* |
150
|
|
|
* @ORM\ManyToOne(targetEntity="Kunstmaan\MediaBundle\Entity\Media") |
151
|
|
|
* @ORM\JoinColumn(name="twitter_image_id", referencedColumnName="id") |
152
|
|
|
*/ |
153
|
|
|
protected $twitterImage; |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param string $url |
157
|
|
|
* |
158
|
|
|
* @return Seo |
159
|
|
|
*/ |
160
|
1 |
|
public function setOgUrl($url) |
161
|
|
|
{ |
162
|
1 |
|
$this->ogUrl = $url; |
163
|
|
|
|
164
|
1 |
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return string |
169
|
|
|
*/ |
170
|
1 |
|
public function getOgUrl() |
171
|
|
|
{ |
172
|
1 |
|
return $this->ogUrl; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @return string |
177
|
|
|
*/ |
178
|
2 |
|
public function getMetaTitle() |
179
|
|
|
{ |
180
|
2 |
|
return $this->metaTitle; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @param string $title |
185
|
|
|
* |
186
|
|
|
* @return string |
|
|
|
|
187
|
|
|
*/ |
188
|
2 |
|
public function setMetaTitle($title) |
189
|
|
|
{ |
190
|
2 |
|
$this->metaTitle = $title; |
191
|
|
|
|
192
|
2 |
|
return $this; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return string |
197
|
|
|
*/ |
198
|
1 |
|
public function getMetaAuthor() |
199
|
|
|
{ |
200
|
1 |
|
return $this->metaAuthor; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @param string $meta |
205
|
|
|
* |
206
|
|
|
* @return Seo |
207
|
|
|
*/ |
208
|
1 |
|
public function setMetaAuthor($meta) |
209
|
|
|
{ |
210
|
1 |
|
$this->metaAuthor = $meta; |
211
|
|
|
|
212
|
1 |
|
return $this; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @return string |
217
|
|
|
*/ |
218
|
1 |
|
public function getMetaDescription() |
219
|
|
|
{ |
220
|
1 |
|
return $this->metaDescription; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @param string $meta |
225
|
|
|
* |
226
|
|
|
* @return Seo |
227
|
|
|
*/ |
228
|
1 |
|
public function setMetaDescription($meta) |
229
|
|
|
{ |
230
|
1 |
|
$this->metaDescription = $meta; |
231
|
|
|
|
232
|
1 |
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* @return string |
237
|
|
|
*/ |
238
|
1 |
|
public function getMetaRobots() |
239
|
|
|
{ |
240
|
1 |
|
return $this->metaRobots; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param string $meta |
245
|
|
|
* |
246
|
|
|
* @return Seo |
247
|
|
|
*/ |
248
|
1 |
|
public function setMetaRobots($meta) |
249
|
|
|
{ |
250
|
1 |
|
$this->metaRobots = $meta; |
251
|
|
|
|
252
|
1 |
|
return $this; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @return string |
257
|
|
|
*/ |
258
|
1 |
|
public function getExtraMetadata() |
259
|
|
|
{ |
260
|
1 |
|
return $this->extraMetadata; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* @param string $extraMetadata |
265
|
|
|
* |
266
|
|
|
* @return Seo |
267
|
|
|
*/ |
268
|
1 |
|
public function setExtraMetadata($extraMetadata) |
269
|
|
|
{ |
270
|
1 |
|
$this->extraMetadata = $extraMetadata; |
271
|
|
|
|
272
|
1 |
|
return $this; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @param string $ogDescription |
277
|
|
|
* |
278
|
|
|
* @return Seo |
279
|
|
|
*/ |
280
|
1 |
|
public function setOgDescription($ogDescription) |
281
|
|
|
{ |
282
|
1 |
|
$this->ogDescription = $ogDescription; |
283
|
|
|
|
284
|
1 |
|
return $this; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @return mixed |
|
|
|
|
289
|
|
|
*/ |
290
|
1 |
|
public function getOgDescription() |
291
|
|
|
{ |
292
|
1 |
|
return $this->ogDescription; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @param Media $ogImage |
|
|
|
|
297
|
|
|
* |
298
|
|
|
* @return Seo |
299
|
|
|
*/ |
300
|
2 |
|
public function setOgImage(Media $ogImage = null) |
301
|
|
|
{ |
302
|
2 |
|
$this->ogImage = $ogImage; |
303
|
|
|
|
304
|
2 |
|
return $this; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @return mixed |
|
|
|
|
309
|
|
|
*/ |
310
|
2 |
|
public function getOgImage() |
311
|
|
|
{ |
312
|
2 |
|
return $this->ogImage; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @param string $ogTitle |
317
|
|
|
* |
318
|
|
|
* @return Seo |
319
|
|
|
*/ |
320
|
1 |
|
public function setOgTitle($ogTitle) |
321
|
|
|
{ |
322
|
1 |
|
$this->ogTitle = $ogTitle; |
323
|
|
|
|
324
|
1 |
|
return $this; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* @return mixed |
|
|
|
|
329
|
|
|
*/ |
330
|
1 |
|
public function getOgTitle() |
331
|
|
|
{ |
332
|
1 |
|
return $this->ogTitle; |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* @param string $ogType |
337
|
|
|
* |
338
|
|
|
* @return Seo |
339
|
|
|
*/ |
340
|
1 |
|
public function setOgType($ogType) |
341
|
|
|
{ |
342
|
1 |
|
$this->ogType = $ogType; |
343
|
|
|
|
344
|
1 |
|
return $this; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* @return mixed |
|
|
|
|
349
|
|
|
*/ |
350
|
1 |
|
public function getOgType() |
351
|
|
|
{ |
352
|
1 |
|
return $this->ogType; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* @return mixed |
357
|
|
|
*/ |
358
|
1 |
|
public function getOgArticleAuthor() |
359
|
|
|
{ |
360
|
1 |
|
return $this->ogArticleAuthor; |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* @param mixed $ogArticleAuthor |
365
|
|
|
*/ |
366
|
1 |
|
public function setOgArticleAuthor($ogArticleAuthor) |
367
|
|
|
{ |
368
|
1 |
|
$this->ogArticleAuthor = $ogArticleAuthor; |
369
|
1 |
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* @return mixed |
373
|
|
|
*/ |
374
|
1 |
|
public function getOgArticlePublisher() |
375
|
|
|
{ |
376
|
1 |
|
return $this->ogArticlePublisher; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* @param mixed $ogArticlePublisher |
381
|
|
|
*/ |
382
|
1 |
|
public function setOgArticlePublisher($ogArticlePublisher) |
383
|
|
|
{ |
384
|
1 |
|
$this->ogArticlePublisher = $ogArticlePublisher; |
385
|
1 |
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @return mixed |
389
|
|
|
*/ |
390
|
1 |
|
public function getOgArticleSection() |
391
|
|
|
{ |
392
|
1 |
|
return $this->ogArticleSection; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* @param mixed $ogArticleSection |
397
|
|
|
*/ |
398
|
1 |
|
public function setOgArticleSection($ogArticleSection) |
399
|
|
|
{ |
400
|
1 |
|
$this->ogArticleSection = $ogArticleSection; |
401
|
1 |
|
} |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* @return string |
405
|
|
|
*/ |
406
|
1 |
|
public function getTwitterTitle() |
407
|
|
|
{ |
408
|
1 |
|
return $this->twitterTitle; |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* @param string $twitterTitle |
413
|
|
|
*/ |
414
|
1 |
|
public function setTwitterTitle($twitterTitle) |
415
|
|
|
{ |
416
|
1 |
|
$this->twitterTitle = $twitterTitle; |
417
|
1 |
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* @return string |
421
|
|
|
*/ |
422
|
1 |
|
public function getTwitterDescription() |
423
|
|
|
{ |
424
|
1 |
|
return $this->twitterDescription; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* @param string $twitterDescription |
429
|
|
|
*/ |
430
|
1 |
|
public function setTwitterDescription($twitterDescription) |
431
|
|
|
{ |
432
|
1 |
|
$this->twitterDescription = $twitterDescription; |
433
|
1 |
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* @return string |
437
|
|
|
*/ |
438
|
1 |
|
public function getTwitterSite() |
439
|
|
|
{ |
440
|
1 |
|
return $this->twitterSite; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* @param string $twitterSite |
445
|
|
|
*/ |
446
|
1 |
|
public function setTwitterSite($twitterSite) |
447
|
|
|
{ |
448
|
1 |
|
$this->twitterSite = $twitterSite; |
449
|
1 |
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* @return string |
453
|
|
|
*/ |
454
|
1 |
|
public function getTwitterCreator() |
455
|
|
|
{ |
456
|
1 |
|
return $this->twitterCreator; |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* @param string $twitterCreator |
461
|
|
|
*/ |
462
|
1 |
|
public function setTwitterCreator($twitterCreator) |
463
|
|
|
{ |
464
|
1 |
|
$this->twitterCreator = $twitterCreator; |
465
|
1 |
|
} |
466
|
|
|
|
467
|
|
|
/** |
468
|
|
|
* @return Media |
469
|
|
|
*/ |
470
|
2 |
|
public function getTwitterImage() |
471
|
|
|
{ |
472
|
2 |
|
return $this->twitterImage; |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* @param Media $twitterImage |
477
|
|
|
*/ |
478
|
2 |
|
public function setTwitterImage($twitterImage) |
479
|
|
|
{ |
480
|
2 |
|
$this->twitterImage = $twitterImage; |
481
|
2 |
|
} |
482
|
|
|
|
483
|
|
|
/** |
484
|
|
|
* Get refId |
485
|
|
|
* |
486
|
|
|
* @return int |
487
|
|
|
*/ |
488
|
|
|
public function getRefId() |
489
|
|
|
{ |
490
|
|
|
return $this->refId; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Set refId |
495
|
|
|
* |
496
|
|
|
* @param int $refId |
497
|
|
|
* |
498
|
|
|
* @return Seo |
499
|
|
|
*/ |
500
|
1 |
|
protected function setRefId($refId) |
501
|
|
|
{ |
502
|
1 |
|
$this->refId = $refId; |
503
|
|
|
|
504
|
1 |
|
return $this; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* Set reference entity name |
509
|
|
|
* |
510
|
|
|
* @param string $refEntityName |
511
|
|
|
* |
512
|
|
|
* @return Seo |
513
|
|
|
*/ |
514
|
1 |
|
protected function setRefEntityName($refEntityName) |
515
|
|
|
{ |
516
|
1 |
|
$this->refEntityName = $refEntityName; |
517
|
|
|
|
518
|
1 |
|
return $this; |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
/** |
522
|
|
|
* Get reference entity name |
523
|
|
|
* |
524
|
|
|
* @return string |
525
|
|
|
*/ |
526
|
|
|
public function getRefEntityName() |
527
|
|
|
{ |
528
|
|
|
return $this->refEntityName; |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
/** |
532
|
|
|
* @param AbstractEntity $entity |
533
|
|
|
* |
534
|
|
|
* @return Seo |
535
|
|
|
*/ |
536
|
1 |
|
public function setRef(AbstractEntity $entity) |
537
|
|
|
{ |
538
|
1 |
|
$this->setRefId($entity->getId()); |
539
|
1 |
|
$this->setRefEntityName(ClassLookup::getClass($entity)); |
540
|
|
|
|
541
|
1 |
|
return $this; |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* @param EntityManager $em |
546
|
|
|
* |
547
|
|
|
* @return AbstractEntity |
|
|
|
|
548
|
|
|
*/ |
549
|
|
|
public function getRef(EntityManager $em) |
550
|
|
|
{ |
551
|
|
|
return $em->getRepository($this->getRefEntityName())->find($this->getRefId()); |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* @return string |
556
|
|
|
*/ |
557
|
1 |
|
public function getDefaultAdminType() |
558
|
|
|
{ |
559
|
1 |
|
return SeoType::class; |
560
|
|
|
} |
561
|
|
|
} |
562
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.