-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAppComponent.php
96 lines (88 loc) · 2.89 KB
/
AppComponent.php
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
86
87
88
89
90
91
92
93
94
95
<?php
/**
* Component for providing a AppController with Ctk capabilities.
*
* PHP 5
*
* Cake Toolkit (http://caketoolkit.org)
* Copyright 2012, James Watts (http://github.com/jameswatts)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2012, James Watts (http://github.com/jameswatts)
* @link http://caketoolkit.org Cake Toolkit
* @package Ctk.Controller.Component
* @since CakePHP(tm) v 2.2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Component', 'Controller');
class AppComponent extends Component {
/**
* An array containing the names of helpers this controller uses. The array elements should
* not contain the "Helper" part of the classname.
*
* @var mixed A single name as a string or a list of names as an array.
*/
public $helpers = null;
/**
* The name of the layout file to render the view inside of. The name specified
* is the filename of the layout in /app/View/Layouts without the .ctp
* extension.
*
* @var string
*/
public $layout = null;
/**
* Used to define methods a controller that will be cached. To cache a
* single action, the value is set to an array containing keys that match
* action names and values that denote cache expiration times (in seconds).
*
* $cacheAction can also be set to a strtotime() compatible string. This
* marks all the actions in the controller for view caching.
*
* @var mixed
*/
public $cacheAction = false;
/**
* Determines which actions of the controller should not have their views rendered
* using the `Ctk` base view. Can be a single action as a string, or an array of
* actions to ignore.
*
* @var mixed
*/
public $ignoreAction = null;
/**
* Called before the Controller::beforeRender(), and before
* the view class is loaded, and before Controller::render()
*
* @param Controller $controller Controller with components to beforeRender
* @return void
*/
public function beforeRender(Controller $controller) {
if (!$this->ignoreAction || ((is_string($this->ignoreAction) && $this->ignoreAction != $controller->action) || (is_array($this->ignoreAction) && !in_array($controller->action, $this->ignoreAction)))) {
$controller->viewClass = 'Ctk.CtkBase';
if (is_array($this->helpers)) {
if (!is_array($controller->helpers)) {
$controller->helpers = $this->helpers;
} else {
array_merge($controller->helpers, $this->helpers);
}
}
if (is_string($this->layout)) {
$controller->layout = $this->layout;
} else {
if (!is_string($controller->layout)) {
$controller->layout = 'Ctk.default';
}
}
if (is_array($this->cacheAction)) {
if (!is_array($controller->cacheAction)) {
$controller->cacheAction = $this->cacheAction;
} else {
array_merge($controller->cacheAction, $this->cacheAction);
}
}
}
}
}