1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Superdesk Web Publisher Content Bundle. |
7
|
|
|
* |
8
|
|
|
* Copyright 2018 Sourcefabric z.ú. and contributors. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please see the |
11
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
12
|
|
|
* |
13
|
|
|
* @copyright 2018 Sourcefabric z.ú |
14
|
|
|
* @license http://www.superdesk.org/license |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace SWP\Bundle\ContentBundle\Model; |
18
|
|
|
|
19
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
20
|
|
|
use Doctrine\Common\Collections\Collection; |
21
|
|
|
use SWP\Component\Common\Model\SoftDeletableTrait; |
22
|
|
|
use SWP\Component\Common\Model\TimestampableTrait; |
23
|
|
|
|
24
|
|
|
class Slideshow implements SlideshowInterface |
25
|
|
|
{ |
26
|
|
|
use TimestampableTrait, SoftDeletableTrait; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string|null |
30
|
|
|
*/ |
31
|
|
|
protected $id; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $code; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var ArticleInterface|null |
40
|
|
|
*/ |
41
|
|
|
protected $article; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var Collection |
45
|
|
|
*/ |
46
|
|
|
protected $items; |
47
|
|
|
|
48
|
|
|
public function __construct() |
49
|
|
|
{ |
50
|
|
|
$this->items = new ArrayCollection(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getId() |
54
|
|
|
{ |
55
|
|
|
return $this->id; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getCode(): string |
59
|
|
|
{ |
60
|
|
|
return $this->code; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setCode(string $code): void |
64
|
|
|
{ |
65
|
|
|
$this->code = $code; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getArticle(): ?ArticleInterface |
69
|
|
|
{ |
70
|
|
|
return $this->article; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function setArticle(?ArticleInterface $article): void |
74
|
|
|
{ |
75
|
|
|
$this->article = $article; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getItems(): Collection |
79
|
|
|
{ |
80
|
|
|
return $this->items; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function setItems(Collection $items): void |
84
|
|
|
{ |
85
|
|
|
$this->items = $items; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function addItem(SlideshowItemInterface $item): void |
89
|
|
|
{ |
90
|
|
|
if (!$this->hasItem($item)) { |
91
|
|
|
$item->setSlideshow($this); |
92
|
|
|
$this->items->add($item); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function hasItem(SlideshowItemInterface $item): bool |
97
|
|
|
{ |
98
|
|
|
return $this->items->contains($item); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|