|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Controller |
|
17 * @subpackage Zend_Controller_Action_Helper |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: Abstract.php 20261 2010-01-13 18:55:25Z matthew $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Controller_Action |
|
25 */ |
|
26 require_once 'Zend/Controller/Action.php'; |
|
27 |
|
28 /** |
|
29 * @category Zend |
|
30 * @package Zend_Controller |
|
31 * @subpackage Zend_Controller_Action_Helper |
|
32 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
33 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
34 */ |
|
35 abstract class Zend_Controller_Action_Helper_Abstract |
|
36 { |
|
37 /** |
|
38 * $_actionController |
|
39 * |
|
40 * @var Zend_Controller_Action $_actionController |
|
41 */ |
|
42 protected $_actionController = null; |
|
43 |
|
44 /** |
|
45 * @var mixed $_frontController |
|
46 */ |
|
47 protected $_frontController = null; |
|
48 |
|
49 /** |
|
50 * setActionController() |
|
51 * |
|
52 * @param Zend_Controller_Action $actionController |
|
53 * @return Zend_Controller_ActionHelper_Abstract Provides a fluent interface |
|
54 */ |
|
55 public function setActionController(Zend_Controller_Action $actionController = null) |
|
56 { |
|
57 $this->_actionController = $actionController; |
|
58 return $this; |
|
59 } |
|
60 |
|
61 /** |
|
62 * Retrieve current action controller |
|
63 * |
|
64 * @return Zend_Controller_Action |
|
65 */ |
|
66 public function getActionController() |
|
67 { |
|
68 return $this->_actionController; |
|
69 } |
|
70 |
|
71 /** |
|
72 * Retrieve front controller instance |
|
73 * |
|
74 * @return Zend_Controller_Front |
|
75 */ |
|
76 public function getFrontController() |
|
77 { |
|
78 return Zend_Controller_Front::getInstance(); |
|
79 } |
|
80 |
|
81 /** |
|
82 * Hook into action controller initialization |
|
83 * |
|
84 * @return void |
|
85 */ |
|
86 public function init() |
|
87 { |
|
88 } |
|
89 |
|
90 /** |
|
91 * Hook into action controller preDispatch() workflow |
|
92 * |
|
93 * @return void |
|
94 */ |
|
95 public function preDispatch() |
|
96 { |
|
97 } |
|
98 |
|
99 /** |
|
100 * Hook into action controller postDispatch() workflow |
|
101 * |
|
102 * @return void |
|
103 */ |
|
104 public function postDispatch() |
|
105 { |
|
106 } |
|
107 |
|
108 /** |
|
109 * getRequest() - |
|
110 * |
|
111 * @return Zend_Controller_Request_Abstract $request |
|
112 */ |
|
113 public function getRequest() |
|
114 { |
|
115 $controller = $this->getActionController(); |
|
116 if (null === $controller) { |
|
117 $controller = $this->getFrontController(); |
|
118 } |
|
119 |
|
120 return $controller->getRequest(); |
|
121 } |
|
122 |
|
123 /** |
|
124 * getResponse() - |
|
125 * |
|
126 * @return Zend_Controller_Response_Abstract $response |
|
127 */ |
|
128 public function getResponse() |
|
129 { |
|
130 $controller = $this->getActionController(); |
|
131 if (null === $controller) { |
|
132 $controller = $this->getFrontController(); |
|
133 } |
|
134 |
|
135 return $controller->getResponse(); |
|
136 } |
|
137 |
|
138 /** |
|
139 * getName() |
|
140 * |
|
141 * @return string |
|
142 */ |
|
143 public function getName() |
|
144 { |
|
145 $full_class_name = get_class($this); |
|
146 |
|
147 if (strpos($full_class_name, '_') !== false) { |
|
148 $helper_name = strrchr($full_class_name, '_'); |
|
149 return ltrim($helper_name, '_'); |
|
150 } else { |
|
151 return $full_class_name; |
|
152 } |
|
153 } |
|
154 } |