1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Superdesk Web Publisher Content List Component. |
7
|
|
|
* |
8
|
|
|
* Copyright 2016 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 2016 Sourcefabric z.ú |
14
|
|
|
* @license http://www.superdesk.org/license |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace SWP\Component\ContentList\Model; |
18
|
|
|
|
19
|
|
|
use SWP\Component\Common\Model\EnableableTrait; |
20
|
|
|
use SWP\Component\Common\Model\SoftDeletableTrait; |
21
|
|
|
use SWP\Component\Common\Model\TimestampableTrait; |
22
|
|
|
|
23
|
|
|
class ContentList implements ContentListInterface |
24
|
|
|
{ |
25
|
|
|
use TimestampableTrait, SoftDeletableTrait, EnableableTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var mixed |
29
|
|
|
*/ |
30
|
|
|
protected $id; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $name; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string|null |
39
|
|
|
*/ |
40
|
|
|
protected $description; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $type; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var int |
49
|
|
|
*/ |
50
|
|
|
protected $cacheLifeTime; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var int |
54
|
|
|
*/ |
55
|
|
|
protected $limit; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var array |
59
|
|
|
*/ |
60
|
|
|
protected $filters = []; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* ContentList constructor. |
64
|
|
|
*/ |
65
|
|
|
public function __construct() |
66
|
|
|
{ |
67
|
|
|
$this->createdAt = new \DateTime(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
17 |
|
*/ |
73
|
|
|
public function getId() |
74
|
17 |
|
{ |
75
|
17 |
|
return $this->id; |
76
|
17 |
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
*/ |
81
|
14 |
|
public function getName() |
82
|
|
|
{ |
83
|
14 |
|
return $this->name; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
12 |
|
public function setName(string $name) |
90
|
|
|
{ |
91
|
12 |
|
$this->name = $name; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* {@inheritdoc} |
96
|
|
|
*/ |
97
|
17 |
|
public function getDescription() |
98
|
|
|
{ |
99
|
17 |
|
return $this->description; |
100
|
17 |
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* {@inheritdoc} |
104
|
|
|
*/ |
105
|
12 |
|
public function setDescription(string $description = null) |
106
|
|
|
{ |
107
|
12 |
|
$this->description = $description; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* {@inheritdoc} |
112
|
|
|
*/ |
113
|
13 |
|
public function getType() |
114
|
|
|
{ |
115
|
13 |
|
return $this->type; |
116
|
13 |
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* {@inheritdoc} |
120
|
|
|
*/ |
121
|
12 |
|
public function setType(string $type) |
122
|
|
|
{ |
123
|
12 |
|
$this->type = $type; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* {@inheritdoc} |
128
|
|
|
*/ |
129
|
16 |
|
public function getCacheLifeTime() |
130
|
|
|
{ |
131
|
16 |
|
return $this->cacheLifeTime; |
132
|
16 |
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* {@inheritdoc} |
136
|
|
|
*/ |
137
|
12 |
|
public function setCacheLifeTime(int $cacheLifeTime = 0) |
138
|
|
|
{ |
139
|
12 |
|
$this->cacheLifeTime = $cacheLifeTime; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* {@inheritdoc} |
144
|
|
|
*/ |
145
|
13 |
|
public function getLimit() |
146
|
|
|
{ |
147
|
13 |
|
return $this->limit; |
148
|
13 |
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* {@inheritdoc} |
152
|
|
|
*/ |
153
|
12 |
|
public function setLimit(int $limit = 0) |
154
|
|
|
{ |
155
|
12 |
|
$this->limit = $limit; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* {@inheritdoc} |
160
|
|
|
*/ |
161
|
13 |
|
public function getFilters() |
162
|
|
|
{ |
163
|
13 |
|
return $this->filters; |
164
|
13 |
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* {@inheritdoc} |
168
|
|
|
*/ |
169
|
2 |
|
public function setFilters(array $filters) |
170
|
|
|
{ |
171
|
2 |
|
$this->filters = $filters; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* {@inheritdoc} |
176
|
|
|
*/ |
177
|
|
|
public function getFilter(string $key) |
178
|
|
|
{ |
179
|
|
|
$filters = $this->getFilters(); |
180
|
|
|
|
181
|
|
|
if (isset($filters[$key])) { |
182
|
|
|
return $filters[$key]; |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
|