|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Superdesk Web Publisher Core Bundle. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright 2016 Sourcefabric z.u. 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\Bundle\CoreBundle\Theme\Model; |
|
18
|
|
|
|
|
19
|
|
|
use SWP\Bundle\CoreBundle\Theme\Helper\ThemeHelper; |
|
20
|
|
|
use Sylius\Bundle\ThemeBundle\Model\Theme as BaseTheme; |
|
21
|
|
|
|
|
22
|
|
|
class Theme extends BaseTheme implements ThemeInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var array |
|
26
|
|
|
*/ |
|
27
|
99 |
|
protected $config; |
|
28
|
|
|
|
|
29
|
99 |
|
/** |
|
30
|
99 |
|
* @var \SplFileInfo |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $logo; |
|
33
|
99 |
|
|
|
34
|
99 |
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $logoPath; |
|
38
|
|
|
|
|
39
|
7 |
|
/** |
|
40
|
|
|
* @var array |
|
41
|
7 |
|
*/ |
|
42
|
7 |
|
protected $generatedData = [ |
|
43
|
|
|
'routes' => [], |
|
44
|
|
|
'menus' => [], |
|
45
|
|
|
'containers' => [], |
|
46
|
|
|
'widgets' => [], |
|
47
|
|
|
'contentLists' => [], |
|
48
|
|
|
]; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var array |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $settings = []; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Theme constructor. |
|
57
|
|
|
* |
|
58
|
|
|
* @param string $name |
|
59
|
|
|
* @param string $path |
|
60
|
|
|
*/ |
|
61
|
|
|
public function __construct($name, $path) |
|
62
|
|
|
{ |
|
63
|
|
|
if ($tempName = strstr($name, ThemeHelper::SUFFIX_SEPARATOR, true)) { |
|
64
|
|
|
$name = $tempName; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
parent::__construct($name, $path); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* {@inheritdoc} |
|
72
|
|
|
*/ |
|
73
|
|
|
public function setName($name) |
|
74
|
|
|
{ |
|
75
|
|
|
$this->name = $name; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* {@inheritdoc} |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getDefaultTemplates(): array |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->config['defaultTemplates']; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* {@inheritdoc} |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getRoutes(): array |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->generatedData['routes']; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* {@inheritdoc} |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getMenus(): array |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->generatedData['menus']; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* {@inheritdoc} |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getContainers(): array |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->generatedData['containers']; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* {@inheritdoc} |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getWidgets(): array |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->generatedData['widgets']; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* {@inheritdoc} |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getContentLists(): array |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->generatedData['contentLists']; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* {@inheritdoc} |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getLogo(): ?\SplFileInfo |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->logo; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* {@inheritdoc} |
|
136
|
|
|
*/ |
|
137
|
|
|
public function setLogo(?\SplFileInfo $file): void |
|
138
|
|
|
{ |
|
139
|
|
|
$this->logo = $file; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* {@inheritdoc} |
|
144
|
|
|
*/ |
|
145
|
|
|
public function getSettings(): array |
|
146
|
|
|
{ |
|
147
|
|
|
return $this->settings; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* {@inheritdoc} |
|
152
|
|
|
*/ |
|
153
|
|
|
public function setSettings(array $settings): void |
|
154
|
|
|
{ |
|
155
|
|
|
$this->settings = $settings; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* {@inheritdoc} |
|
160
|
|
|
*/ |
|
161
|
|
|
public function getLogoPath(): ?string |
|
162
|
|
|
{ |
|
163
|
|
|
return $this->logoPath; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* {@inheritdoc} |
|
168
|
|
|
*/ |
|
169
|
|
|
public function setLogoPath(?string $path): void |
|
170
|
|
|
{ |
|
171
|
|
|
$this->logoPath = $path; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* {@inheritdoc} |
|
176
|
|
|
*/ |
|
177
|
|
|
public function hasLogo(): bool |
|
178
|
|
|
{ |
|
179
|
|
|
return null !== $this->logo; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* {@inheritdoc} |
|
184
|
|
|
*/ |
|
185
|
|
|
public function serialize(): string |
|
186
|
|
|
{ |
|
187
|
|
|
return serialize([ |
|
188
|
|
|
$this->name, |
|
189
|
|
|
$this->description, |
|
190
|
|
|
$this->path, |
|
191
|
|
|
$this->title, |
|
192
|
|
|
$this->logoPath, |
|
193
|
|
|
]); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* {@inheritdoc} |
|
198
|
|
|
*/ |
|
199
|
|
|
public function unserialize($serialized): void |
|
200
|
|
|
{ |
|
201
|
|
|
[ |
|
202
|
|
|
$this->name, |
|
203
|
|
|
$this->description, |
|
204
|
|
|
$this->path, |
|
205
|
|
|
$this->title, |
|
206
|
|
|
$this->logoPath |
|
207
|
|
|
] = unserialize($serialized); |
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
|