//Zend_Controller_Action_Helper_Smarty 【二】自定义动作助手 【zend框架】 <?php /** * smarty自定义动作助手 * 一下代码应该放在抽象类中 这样会更好 * @author wolf [Email: 116311316] * */ class Custom_Controller_Action_Helper_Smarty { protected $_smartyConfig; protected $_tmpPath; protected $_actionController; protected $_request; /** * 获取配置 * @param unknown_type $tmpPath * @param array $config */ public function __construct($tmpPath, array $config) { $this->_smartyConfig = $config; $this->_tmpPath = $tmpPath; } /** * 获取当前控制器 * @param $actionController */ public function setActionController($actionController){ return $this->_actionController=$actionController; } /** * 存储路由之后的request * @param $request */ public function setRequest($request){ return $this->_request=$request; } /** * 获得smarty对象 */ public function preDispatch() { $modules=$this->_request->getModuleName(); $smarty = new Custom_View_Smarty($this->_tmpPath, $this->_smartyConfig,$modules); $this->_actionController->smarty = $smarty; } }