forked from cakephp/plugins.cakephp.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppView.php
More file actions
85 lines (79 loc) · 2.51 KB
/
Copy pathAppView.php
File metadata and controls
85 lines (79 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace App\View;
use BootstrapUI\View\UIViewTrait;
use Cake\Event\EventListenerInterface;
use Cake\View\View;
/**
* Application View
*
* Your application’s default view class
*
* @link http://book.cakephp.org/3.0/en/views.html#the-app-view
*
* @property \App\View\Helper\ResourceHelper $Resource
* @property \App\View\Helper\MenuHelper $Menu
* @property \AssetCompress\View\Helper\AssetCompressHelper $AssetCompress
*/
class AppView extends View implements EventListenerInterface
{
use UIViewTrait;
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading helpers.
*
* e.g. `$this->loadHelper('Html');`
*
* @return void
*/
public function initialize()
{
\Cake\Log\Log::info(json_encode($this->request->getAttributes() + ['referer' => $this->request->referer()]));
$this->initializeUI(['layout' => $this->layout]);
$this->loadHelper('AssetCompress.AssetCompress');
$this->loadHelper('Menu');
$this->loadHelper('Form');
$this->loadHelper('Resource');
$this->loadHelper('ButtonGroup');
$this->getEventManager()->on($this);
}
/**
* Returns a list of all events that this View class will listen to.
*
* @return array List of events this class listens to. Defaults to `[]`.
*/
public function implementedEvents()
{
return [
'View.beforeLayout' => 'beforeLayout',
];
}
/**
* View.beforeLayout event
*
* @param string $layoutFileName Name of layout being rendered
* @return void
* @throws \Cake\Core\Exception\Exception if there is an error in the view.
*/
public function beforeLayout($layoutFileName)
{
$controllerName = lcfirst($this->request->getParam('controller'));
$actionName = $this->request->getParam('action');
$this->set([
'_bodyId' => $controllerName,
'_bodyClass' => "{$controllerName}-{$actionName}",
]);
}
}