|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* CakeCMS Core |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the of the simple cms based on CakePHP 3. |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
* |
|
9
|
|
|
* @package Core |
|
10
|
|
|
* @license MIT |
|
11
|
|
|
* @copyright MIT License http://www.opensource.org/licenses/mit-license.php |
|
12
|
|
|
* @link https://github.com/CakeCMS/Core". |
|
13
|
|
|
* @author Sergey Kalistratov <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Core\View; |
|
17
|
|
|
|
|
18
|
|
|
use Core\Plugin; |
|
19
|
|
|
use Cake\View\View; |
|
20
|
|
|
use Cake\Event\Event; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class AppView |
|
24
|
|
|
* |
|
25
|
|
|
* @package Core\View |
|
26
|
|
|
*/ |
|
27
|
|
|
class AppView extends View |
|
28
|
|
|
{ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Initialization hook method. |
|
32
|
|
|
* |
|
33
|
|
|
* Properties like $helpers etc. cannot be initialized statically in your custom |
|
34
|
|
|
* view class as they are overwritten by values from controller in constructor. |
|
35
|
|
|
* So this method allows you to manipulate them as required after view instance |
|
36
|
|
|
* is constructed. |
|
37
|
|
|
* |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
|
|
public function initialize() |
|
41
|
|
|
{ |
|
42
|
|
|
parent::initialize(); |
|
43
|
|
|
Plugin::manifestEvent('View.initialize', $this); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Is called before each view file is rendered. This includes elements, views, parent views and layouts. |
|
48
|
|
|
* |
|
49
|
|
|
* @param Event $event |
|
50
|
|
|
* @param string $viewFile |
|
51
|
|
|
* @return void |
|
52
|
|
|
*/ |
|
53
|
|
|
public function beforeRenderFile(Event $event, $viewFile) |
|
54
|
|
|
{ |
|
55
|
|
|
Plugin::manifestEvent('View.beforeRenderFile', $this, $event, $viewFile); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Is called after each view file is rendered. This includes elements, views, parent views and layouts. |
|
60
|
|
|
* A callback can modify and return $content to change how the rendered content will be displayed in the browser. |
|
61
|
|
|
* |
|
62
|
|
|
* @param Event $event |
|
63
|
|
|
* @param string $viewFile |
|
64
|
|
|
* @param string $content |
|
65
|
|
|
* @return void |
|
66
|
|
|
*/ |
|
67
|
|
|
public function afterRenderFile(Event $event, $viewFile, $content) |
|
68
|
|
|
{ |
|
69
|
|
|
Plugin::manifestEvent('View.afterRenderFile', $this, $event, $viewFile, $content); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Is called after the controller’s beforeRender method but before the controller renders view and layout. |
|
74
|
|
|
* Receives the file being rendered as an argument. |
|
75
|
|
|
* |
|
76
|
|
|
* @param Event $event |
|
77
|
|
|
* @param string $viewFile |
|
78
|
|
|
* @return void |
|
79
|
|
|
*/ |
|
80
|
|
|
public function beforeRender(Event $event, $viewFile) |
|
81
|
|
|
{ |
|
82
|
|
|
Plugin::manifestEvent('View.beforeRender', $this, $event, $viewFile); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Is called after the view has been rendered but before layout rendering has started. |
|
87
|
|
|
* |
|
88
|
|
|
* @param Event $event |
|
89
|
|
|
* @param string $viewFile |
|
90
|
|
|
* @return void |
|
91
|
|
|
*/ |
|
92
|
|
|
public function afterRender(Event $event, $viewFile) |
|
93
|
|
|
{ |
|
94
|
|
|
Plugin::manifestEvent('View.afterRender', $this, $event, $viewFile); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Is called before layout rendering starts. Receives the layout filename as an argument. |
|
99
|
|
|
* |
|
100
|
|
|
* @param Event $event |
|
101
|
|
|
* @param string $layoutFile |
|
102
|
|
|
* @return void |
|
103
|
|
|
*/ |
|
104
|
|
|
public function beforeLayout(Event $event, $layoutFile) |
|
105
|
|
|
{ |
|
106
|
|
|
Plugin::manifestEvent('View.beforeLayout', $this, $event, $layoutFile); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Is called after layout rendering is complete. Receives the layout filename as an argument. |
|
111
|
|
|
* |
|
112
|
|
|
* @param Event $event |
|
113
|
|
|
* @param string $layoutFile |
|
114
|
|
|
* @return void |
|
115
|
|
|
*/ |
|
116
|
|
|
public function afterLayout(Event $event, $layoutFile) |
|
117
|
|
|
{ |
|
118
|
|
|
Plugin::manifestEvent('View.beforeLayout', $this, $event, $layoutFile); |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|