Completed
Pull Request — experimental/sf (#3244)
by k-yamamura
41:50
created

TemplateEvent::removePluginJavascripts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Event;
15
16
use Symfony\Component\EventDispatcher\Event;
17
use Symfony\Component\HttpFoundation\Response;
18
19
/**
20
 * Class TemplateEvent
21
 */
22
class TemplateEvent extends Event
23
{
24
    /**
25
     * @var string
26
     */
27
    private $view;
28
29
    /**
30
     * @var string
31
     */
32
    private $source;
33
34
    /**
35
     * @var array
36
     */
37
    private $parameters;
38
39
    /**
40
     * @var null|Response
41
     */
42
    private $response;
43
44
    /**
45
     * @var array
46
     */
47
    private $plugin_javascripts = [];
48
49
    /**
50
     * @var array
51
     */
52
    private $plugin_assets = [];
53
54
    /**
55
     * @var array
56
     */
57
    private $plugin_snippets = [];
58
59
    /**
60
     * TemplateEvent constructor.
61
     *
62
     * @param string $view
0 ignored issues
show
introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
63
     * @param string $source
0 ignored issues
show
introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
64
     * @param array $parameters
0 ignored issues
show
introduced by
Expected 9 spaces after parameter type; 1 found
Loading history...
65
     * @param Response|null $response
66
     */
67 274
    public function __construct($view, $source, array $parameters = [], Response $response = null)
68
    {
69 274
        $this->view = $view;
70 274
        $this->source = $source;
71 274
        $this->parameters = $parameters;
72 274
        $this->response = $response;
73
    }
74
75
    /**
76
     * @return string
77
     */
78 1
    public function getView()
79
    {
80 1
        return $this->view;
81
    }
82
83
    /**
84
     * @param string $view
85
     */
86 1
    public function setView($view)
87
    {
88 1
        $this->view = $view;
89
    }
90
91
    /**
92
     * @return string
93
     */
94 271
    public function getSource()
95
    {
96 271
        return $this->source;
97
    }
98
99
    /**
100
     * @param string $source
101
     */
102 1
    public function setSource($source)
103
    {
104 1
        $this->source = $source;
105
    }
106
107
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$key" missing
Loading history...
108
     * @param $key
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
109
     *
110
     * @return mixed
111
     */
112
    public function getParameter($key)
113
    {
114
        return $this->parameters[$key];
115
    }
116
117
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$key" missing
Loading history...
introduced by
Doc comment for parameter "$value" missing
Loading history...
118
     * @param $key
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
119
     * @param $value
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
120
     */
121
    public function setParameter($key, $value)
122
    {
123
        $this->parameters[$key] = $value;
124
    }
125
126
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$key" missing
Loading history...
127
     * @param $key
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
128
     *
129
     * @return bool
130
     */
131
    public function hasParameter($key)
132
    {
133
        return isset($this->parameters[$key]);
134
    }
135
136
    /**
137
     * @return array
138
     */
139 271
    public function getParameters()
140
    {
141 271
        return $this->parameters;
142
    }
143
144
    /**
145
     * @param array $parameters
146
     */
147 1
    public function setParameters($parameters)
148
    {
149 1
        $this->parameters = $parameters;
150
    }
151
152
    /**
153
     * @return null|Response
154
     */
155 1
    public function getResponse()
156
    {
157 1
        return $this->response;
158
    }
159
160
    /**
161
     * @param null|Response $response
162
     */
163 1
    public function setResponse($response)
164
    {
165 1
        $this->response = $response;
166
    }
167
168
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$plugin_javascript" missing
Loading history...
169
     * Add plugin_javascripts
170
     *
171
     * @param $plugin_javascript
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
172
     * @param bool $value
0 ignored issues
show
introduced by
Expected 14 spaces after parameter type; 1 found
Loading history...
173
     *
174
     * @return $this
175
     */
176
    public function addPluginJavascripts($plugin_javascript, $value = true)
177
    {
178
        $this->plugin_javascripts[$plugin_javascript] = $value;
179
180
        $this->setParameter('plugin_javascripts', $this->plugin_javascripts);
181
182
        return $this;
183
    }
184
185
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$plugin_javascript" missing
Loading history...
186
     * Remove plugin_javascripts
187
     *
188
     * @param $plugin_javascript
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
189
     */
190
    public function removePluginJavascripts($plugin_javascript)
191
    {
192
        unset($this->plugin_javascripts[$plugin_javascript]);
193
194
        $this->setParameter('plugin_javascripts', $this->plugin_javascripts);
195
    }
196
197
    /**
198
     * Get plugin_javascripts
199
     *
200
     * @return array
201
     */
202
    public function getPluginJavascripts()
203
    {
204
        return $this->plugin_javascripts;
205
    }
206
207
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$plugin_asset" missing
Loading history...
208
     * Add plugin_assets
209
     *
210
     * @param $plugin_asset
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
211
     * @param bool $value
0 ignored issues
show
introduced by
Expected 9 spaces after parameter type; 1 found
Loading history...
212
     *
213
     * @return $this
214
     */
215
    public function addPluginAssets($plugin_asset, $value = true)
216
    {
217
        $this->plugin_assets[$plugin_asset] = $value;
218
219
        $this->setParameter('plugin_assets', $this->plugin_assets);
220
221
        return $this;
222
    }
223
224
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$plugin_asset" missing
Loading history...
225
     * Remove plugin_assets
226
     *
227
     * @param $plugin_asset
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
228
     */
229
    public function removePluginAssets($plugin_asset)
230
    {
231
        unset($this->plugin_assets[$plugin_asset]);
232
233
        $this->setParameter('plugin_assets', $this->plugin_assets);
234
    }
235
236
    /**
237
     * Get plugin_assets
238
     *
239
     * @return array
240
     */
241
    public function getPluginAssets()
242
    {
243
        return $this->plugin_assets;
244
    }
245
246
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$plugin_snippet" missing
Loading history...
247
     * Add plugin_snippets
248
     *
249
     * @param $plugin_snippet
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
250
     * @param bool $value
0 ignored issues
show
introduced by
Expected 11 spaces after parameter type; 1 found
Loading history...
251
     *
252
     * @return $this
253
     */
254
    public function addPluginSnippets($plugin_snippet, $value = true)
255
    {
256
        $this->plugin_snippets[$plugin_snippet] = $value;
257
258
        $this->setParameter('plugin_snippets', $this->plugin_snippets);
259
260
        return $this;
261
    }
262
263
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$plugin_snippet" missing
Loading history...
264
     * Remove plugin_snippets
265
     *
266
     * @param $plugin_snippet
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
267
     */
268
    public function removePluginSnippets($plugin_snippet)
269
    {
270
        unset($this->plugin_snippets[$plugin_snippet]);
271
272
        $this->setParameter('plugin_snippeet', $this->plugin_snippets);
273
    }
274
275
    /**
276
     * Get plugin_snippets
277
     *
278
     * @return array
279
     */
280
    public function getPluginSnippets()
281
    {
282
        return $this->plugin_snippets;
283
    }
284
}
285