summaryrefslogtreecommitdiff
path: root/lib/prado/framework/Web/UI/TControlAdapter.php
blob: 4168e40c0dc1b05fc34f6bc4d9cce7a2d3a7f131 (plain)
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
140
141
<?php
/**
 * TControlAdapter class file.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link https://github.com/pradosoft/prado
 * @copyright Copyright &copy; 2005-2016 The PRADO Group
 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
 * @package System.Web.UI
 */

/**
 * TControlAdapter class
 *
 * TControlAdapter is the base class for adapters that customize
 * various behaviors for the control to which the adapter is attached.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @package System.Web.UI
 * @since 3.0
 */
class TControlAdapter extends TApplicationComponent
{
	/**
	 * @var TControl the control to which the adapter is attached
	 */
	protected $_control;

	/**
	 * Constructor.
	 * @param TControl the control to which the adapter is attached
	 */
	public function __construct($control)
	{
		$this->_control=$control;
	}

	/**
	 * @return TControl the control to which this adapter is attached
	 */
	public function getControl()
	{
		return $this->_control;
	}

	/**
	 * @return TPage the page that contains the attached control
	 */
	public function getPage()
	{
		return $this->_control?$this->_control->getPage():null;
	}

	/**
	 * Creates child controls for the attached control.
	 * Default implementation calls the attached control's corresponding method.
	 */
	public function createChildControls()
	{
		$this->_control->createChildControls();
	}

	/**
	 * Loads additional persistent control state.
	 * Default implementation calls the attached control's corresponding method.
	 */
	public function loadState()
	{
		$this->_control->loadState();
	}

	/**
	 * Saves additional persistent control state.
	 * Default implementation calls the attached control's corresponding method.
	 */
	public function saveState()
	{
		$this->_control->saveState();
	}

	/**
	 * This method is invoked when the control enters 'OnInit' stage.
	 * Default implementation calls the attached control's corresponding method.
	 * @param TEventParameter event parameter to be passed to the event handlers
	 */
	public function onInit($param)
	{
		$this->_control->onInit($param);
	}

	/**
	 * This method is invoked when the control enters 'OnLoad' stage.
	 * Default implementation calls the attached control's corresponding method.
	 * @param TEventParameter event parameter to be passed to the event handlers
	 */
	public function onLoad($param)
	{
		$this->_control->onLoad($param);
	}

	/**
	 * This method is invoked when the control enters 'OnPreRender' stage.
	 * Default implementation calls the attached control's corresponding method.
	 * @param TEventParameter event parameter to be passed to the event handlers
	 */
	public function onPreRender($param)
	{
		$this->_control->onPreRender($param);
	}

	/**
	 * This method is invoked when the control enters 'OnUnload' stage.
	 * Default implementation calls the attached control's corresponding method.
	 * @param TEventParameter event parameter to be passed to the event handlers
	 */
	public function onUnload($param)
	{
		$this->_control->onUnload($param);
	}

	/**
	 * This method is invoked when the control renders itself.
	 * Default implementation calls the attached control's corresponding method.
	 * @param THtmlWriter writer for the rendering purpose
	 */
	public function render($writer)
	{
		$this->_control->render($writer);
	}

	/**
	 * Renders the control's children.
	 * Default implementation calls the attached control's corresponding method.
	 * @param THtmlWriter writer for the rendering purpose
	 */
	public function renderChildren($writer)
	{
		$this->_control->renderChildren($writer);
	}
}