1 | <?php |
||
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 $assets = []; |
||
48 | |||
49 | /** |
||
50 | * @var array |
||
51 | */ |
||
52 | private $snippets = []; |
||
53 | |||
54 | /** |
||
55 | * TemplateEvent constructor. |
||
56 | * |
||
57 | * @param string $view |
||
|
|||
58 | * @param string $source |
||
59 | * @param array $parameters |
||
60 | * @param Response|null $response |
||
61 | */ |
||
62 | 274 | public function __construct($view, $source, array $parameters = [], Response $response = null) |
|
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | 1 | public function getView() |
|
77 | |||
78 | /** |
||
79 | * @param string $view |
||
80 | */ |
||
81 | 1 | public function setView($view) |
|
85 | |||
86 | /** |
||
87 | * @return string |
||
88 | */ |
||
89 | 271 | public function getSource() |
|
93 | |||
94 | /** |
||
95 | * @param string $source |
||
96 | */ |
||
97 | 1 | public function setSource($source) |
|
101 | |||
102 | /** |
||
103 | * @param $key |
||
104 | * |
||
105 | * @return mixed |
||
106 | */ |
||
107 | public function getParameter($key) |
||
111 | |||
112 | /** |
||
113 | * @param $key |
||
114 | * @param $value |
||
115 | */ |
||
116 | public function setParameter($key, $value) |
||
120 | |||
121 | /** |
||
122 | * @param $key |
||
123 | * |
||
124 | * @return bool |
||
125 | */ |
||
126 | public function hasParameter($key) |
||
130 | |||
131 | /** |
||
132 | * @return array |
||
133 | */ |
||
134 | 271 | public function getParameters() |
|
138 | |||
139 | /** |
||
140 | * @param array $parameters |
||
141 | */ |
||
142 | 1 | public function setParameters($parameters) |
|
146 | |||
147 | /** |
||
148 | * @return null|Response |
||
149 | */ |
||
150 | 1 | public function getResponse() |
|
154 | |||
155 | /** |
||
156 | * @param null|Response $response |
||
157 | */ |
||
158 | 1 | public function setResponse($response) |
|
162 | |||
163 | /** |
||
164 | * アセットを追加する |
||
165 | * |
||
166 | * ここで追加したコードは, <head></head>内に出力される |
||
167 | * javascriptの読み込みやcssの読み込みに利用する. |
||
168 | * |
||
169 | * @param $asset |
||
170 | * @param bool $include twigファイルとしてincludeするかどうか |
||
171 | * |
||
172 | * @return $this |
||
173 | */ |
||
174 | public function addAsset($asset, $include = true) |
||
182 | |||
183 | /** |
||
184 | * スニペットを追加する. |
||
185 | * |
||
186 | * ここで追加したコードは, </body>タグ直前に出力される |
||
187 | * |
||
188 | * @param $snippet |
||
189 | * @param bool $include twigファイルとしてincludeするかどうか |
||
190 | * |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function addSnippet($snippet, $include = true) |
||
201 | } |
||
202 |