1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Superdesk Web Publisher Templates System. |
5
|
|
|
* |
6
|
|
|
* Copyright 2015 Sourcefabric z.ú. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2015 Sourcefabric z.ú |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace SWP\Component\TemplatesSystem\Tests\Gimme\Model; |
16
|
|
|
|
17
|
|
|
use SWP\Component\TemplatesSystem\Gimme\Model\WidgetModelInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* WidgetModel. |
21
|
|
|
*/ |
22
|
|
|
class WidgetModel implements WidgetModelInterface |
23
|
|
|
{ |
24
|
|
|
const TYPE_HTML = 1; |
25
|
|
|
|
26
|
|
|
protected $types = [ |
27
|
|
|
self::TYPE_HTML => '\\SWP\\Component\\TemplatesSystem\\Gimme\\WidgetModel\\HtmlWidgetHandler', |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int |
32
|
|
|
*/ |
33
|
|
|
protected $id; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $type; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $name; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var bool |
47
|
|
|
*/ |
48
|
|
|
protected $visible; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var array |
52
|
|
|
*/ |
53
|
|
|
protected $parameters; |
54
|
|
|
|
55
|
|
|
public function __construct() |
56
|
|
|
{ |
57
|
|
|
$this->parameters = []; |
58
|
|
|
$this->setVisible(true); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get id. |
63
|
|
|
* |
64
|
|
|
* @return int |
65
|
|
|
*/ |
66
|
|
|
public function getId() |
67
|
|
|
{ |
68
|
|
|
return $this->id; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Set id. |
73
|
|
|
* |
74
|
|
|
* @param int $id |
75
|
|
|
* |
76
|
|
|
* @return WidgetModel |
77
|
|
|
*/ |
78
|
|
|
public function setId($id) |
79
|
|
|
{ |
80
|
|
|
$this->id = $id; |
81
|
|
|
|
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Set name. |
87
|
|
|
* |
88
|
|
|
* @param string $name |
89
|
|
|
* |
90
|
|
|
* @return WidgetModel |
91
|
|
|
*/ |
92
|
|
|
public function setName($name) |
93
|
|
|
{ |
94
|
|
|
$this->name = $name; |
95
|
|
|
|
96
|
|
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Get name. |
101
|
|
|
* |
102
|
|
|
* @return string |
103
|
|
|
*/ |
104
|
|
|
public function getName() |
105
|
|
|
{ |
106
|
|
|
return $this->name; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Gets the value of visible. |
111
|
|
|
* |
112
|
|
|
* @return bool |
113
|
|
|
*/ |
114
|
|
|
public function getVisible() |
115
|
|
|
{ |
116
|
|
|
return $this->visible; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Sets the value of visible. |
121
|
|
|
* |
122
|
|
|
* @param bool $visible the visible |
123
|
|
|
* |
124
|
|
|
* @return WidgetModel |
125
|
|
|
*/ |
126
|
|
|
public function setVisible($visible) |
127
|
|
|
{ |
128
|
|
|
$this->visible = $visible; |
129
|
|
|
|
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Gets the value of type. |
135
|
|
|
* |
136
|
|
|
* @return int |
137
|
|
|
*/ |
138
|
|
|
public function getType() |
139
|
|
|
{ |
140
|
|
|
return $this->type; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Sets the value of type. |
145
|
|
|
* |
146
|
|
|
* @param int $type the type |
147
|
|
|
* |
148
|
|
|
* @return WidgetModel |
149
|
|
|
*/ |
150
|
|
|
public function setType($type = self::TYPE_HTML) |
151
|
|
|
{ |
152
|
|
|
if (array_key_exists($type, $this->types)) { |
153
|
|
|
$this->type = $this->types[$type]; |
154
|
|
|
} else { |
155
|
|
|
$this->type = $this->types[self::TYPE_HTML]; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Gets the value of parameters. |
163
|
|
|
* |
164
|
|
|
* @return array |
165
|
|
|
*/ |
166
|
|
|
public function getParameters() |
167
|
|
|
{ |
168
|
|
|
return $this->parameters; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Sets the value of parameters. |
173
|
|
|
* |
174
|
|
|
* @param array $parameters the parameters |
175
|
|
|
* |
176
|
|
|
* @return WidgetModel |
177
|
|
|
*/ |
178
|
|
|
public function setParameters($parameters) |
179
|
|
|
{ |
180
|
|
|
$this->parameters = $parameters; |
181
|
|
|
|
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|