-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCtkRenderer.php
140 lines (125 loc) · 2.93 KB
/
CtkRenderer.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* Base renderer class for rendering the view objects.
*
* 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.Lib
* @since CakePHP(tm) v 2.2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('CtkLoadable', 'Ctk.Lib');
App::uses('CtkObject', 'Ctk.Lib');
App::uses('CtkNode', 'Ctk.Lib');
App::uses('CtkView', 'Ctk.View');
/**
* Abstract class for defining view renderers.
*
* @package Ctk.Lib
*/
abstract class CtkRenderer extends CtkObject implements CtkLoadable {
/**
* Settings for this renderer.
*
* @var array
*/
public $settings = array();
/**
* The current view calling the renderer.
*
* @var CtkView The current view.
*/
protected $_view = null;
/**
* The name of this renderer.
*
* @var string The name of the renderer.
*/
protected $_name = null;
/**
* The plugin for this renderer.
*
* @var string The plugin for the renderer.
*/
protected $_plugin = null;
/**
* Contructor
*
* Creates a new renderer with a reference to the current view.
*
* @param CtkView $view The current view.
* @param string $name The name of the renderer.
* @param string $plugin The name of the plugin if it exists.
* @param array $settings Configuration settings for the renderer.
*/
final public function __construct(CtkView $view, $name, $plugin = null, $settings = null) {
parent::__construct();
$this->_view = $view;
$this->_name = (string) $name;
$this->_plugin = (string) $plugin;
if ($settings) {
$this->settings = Set::merge($this->settings, (array) $settings);
}
}
/**
* Returns the view object for this renderer.
*
* @return CtkView
*/
final public function getView() {
return $this->_view;
}
/**
* Returns the name of the current renderer.
*
* @return string
*/
final public function getName() {
return $this->_name;
}
/**
* Returns the plugin for the current renderer.
*
* @return string
*/
final public function getPlugin() {
return $this->_plugin;
}
/**
* Sets the renderer as loaded.
*
* @return void
*/
final public function load() {
self::registerClass($this);
}
/**
* Determines if the renderer has been previously loaded.
*
* @return boolean
*/
final public function isLoaded() {
return self::isClassRegistered($this);
}
/**
* Abstract method used to setup additional resources for the renderer.
*
* @return void
*/
abstract public function setup();
/**
* Abstract method used to render the view objects and return the generated content.
*
* @param CtkObject $object The object being rendered.
* @return string
*/
abstract public function render(CtkObject $object);
}