Completed
Push — master ( 2e9827...ef00d6 )
by Rafał
10:01
created

Theme::setGeneratedData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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 101
    protected $config;
28
29 101
    /**
30 101
     * @var \SplFileInfo
31
     */
32
    protected $logo;
33 101
34 101
    /**
35
     * @var string
36
     */
37
    protected $logoPath;
38
39 7
    /**
40
     * @var array
41 7
     */
42 7
    protected $generatedData = [
43
        'routes' => [],
44
        'menus' => [],
45
        'contentLists' => [],
46
    ];
47
48
    /**
49
     * @var array
50
     */
51
    protected $settings = [];
52
53
    /**
54
     * Theme constructor.
55
     *
56
     * @param string $name
57
     * @param string $path
58
     */
59
    public function __construct($name, $path)
60
    {
61
        if ($tempName = strstr($name, ThemeHelper::SUFFIX_SEPARATOR, true)) {
62
            $name = $tempName;
63
        }
64
        parent::__construct($name, $path);
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function setName($name)
71
    {
72
        $this->name = $name;
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function getDefaultTemplates(): array
79
    {
80
        return $this->config['defaultTemplates'];
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function getRoutes(): array
87
    {
88
        return $this->generatedData['routes'];
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    public function getMenus(): array
95
    {
96
        return $this->generatedData['menus'];
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public function getContentLists(): array
103
    {
104
        return $this->generatedData['contentLists'];
105
    }
106
107
    /**
108
     * {@inheritdoc}
109
     */
110
    public function getLogo(): ?\SplFileInfo
111
    {
112
        return $this->logo;
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118
    public function setLogo(?\SplFileInfo $file): void
119
    {
120
        $this->logo = $file;
121
    }
122
123
    /**
124
     * {@inheritdoc}
125
     */
126
    public function getSettings(): array
127
    {
128
        return $this->settings;
129
    }
130
131
    /**
132
     * {@inheritdoc}
133
     */
134
    public function setSettings(array $settings): void
135
    {
136
        $this->settings = $settings;
137
    }
138
139
    /**
140
     * {@inheritdoc}
141
     */
142
    public function getLogoPath(): ?string
143
    {
144
        return $this->logoPath;
145
    }
146
147
    /**
148
     * {@inheritdoc}
149
     */
150
    public function setLogoPath(?string $path): void
151
    {
152
        $this->logoPath = $path;
153
    }
154
155
    /**
156
     * {@inheritdoc}
157
     */
158
    public function hasLogo(): bool
159
    {
160
        return null !== $this->logo;
161
    }
162
163
    public function setGeneratedData(array $generatedData): void
164
    {
165
        $this->generatedData = $generatedData;
166
    }
167
168
    /**
169
     * {@inheritdoc}
170
     */
171
    public function serialize(): string
172
    {
173
        return serialize([
174
            $this->config,
175
            $this->generatedData,
176
            $this->settings,
177
            $this->name,
178
            $this->description,
179
            $this->path,
180
            $this->title,
181
            $this->logoPath,
182
            $this->parents,
183
            $this->authors,
184
            $this->screenshots,
185
        ]);
186
    }
187
188
    /**
189
     * {@inheritdoc}
190
     */
191
    public function unserialize($serialized): void
192
    {
193
        [
194
            $this->config,
195
            $this->generatedData,
196
            $this->settings,
197
            $this->name,
198
            $this->description,
199
            $this->path,
200
            $this->title,
201
            $this->logoPath,
202
            $this->parents,
203
            $this->authors,
204
            $this->screenshots
205
        ] = unserialize($serialized);
206
    }
207
}
208