Factory pattern in Zend data grid
来源:互联网 发布:最新网络电影预告片 编辑:程序博客网 时间:2024/05/22 12:59
In the abstract class Bvb_Grid, there is static method named factory() which acts as a factory to create specific grid deploy class.
public static function factory($defaultClass = 'Table', $options = array(), $id = '', $classCallbacks = array(), $requestParams = false) { self::initDeployClass();//initialize Zend_Loader_PluginLoader and add the prefix path try { $defaultClass = self::loadDeployClass($defaultClass);// load the deploy class } catch (Zend_Loader_PluginLoader_Exception $e) { if (!class_exists($defaultClass)) { throw $e; } } if (false === $requestParams) { // use request parameters $requestParams = Zend_Controller_Front::getInstance()->getRequest()->getParams(); } if ($options instanceof Zend_Config) { $options = $options->toArray(); } // use this as request parameters if (!isset($options['grid'])) { $options['grid'] = array('requestParams' => $requestParams); } else { $options['grid']['requestParams'] = $requestParams; } // handle _exportTo parameter compatible with calling with grid id and without if (isset($requestParams['_exportTo' . $id])) { $exportTo = $requestParams['_exportTo' . $id]; } elseif (isset($requestParams['_exportTo'])) { $exportTo = $requestParams['_exportTo']; } else { $exportTo = false; } if (false === $exportTo) { // return instance of the main Bvb object, because this is not and export request $grid = new $defaultClass($options); $lClass = $defaultClass; } else { $lClass = strtolower($exportTo); // support translating of parameters specifig for the export initiator class if (isset($requestParams['_exportFrom'])) { // TODO support translating of parameters specifig for the export initiator class $requestParams = $requestParams; } // now we need to find and load the right Bvb deploy class // TODO support user defined classes $className = self::loadDeployClass($exportTo); if (Zend_Loader_Autoloader::autoload($className)) { $grid = new $className($options); } else { $grid = new $defaultClass($options); $lClass = $defaultClass; } } // add the powerfull configuration callback function if (isset($classCallbacks[$lClass])) { $grid->_configCallbacks = $classCallbacks[$lClass]; // register callbacks } if (is_string($id)) { $grid->setGridId($id); } return $grid; }If we want to use one specific grid deploy class, we can also use it directly.
<?phpclass Bvb_Grid_Deploy_Table extends Bvb_Grid implements Bvb_Grid_Deploy_DeployInterface {public function __construct (array $options = array()) { $this->_setRemoveHiddenFields(true); parent::__construct($options); if (isset($this->_options['grid']['id'])) { $this->setGridId($this->_options['grid']['id']); } $this->_gridSession = new Zend_Session_Namespace('Bvb_Grid_' . $this->getGridId()); $this->addTemplateDir('Bvb/Grid/Template', 'Bvb_Grid_Template', 'table'); if ($this->getParam('add') || $this->getParam('edit')) { if ($this->getParam('add')) { $this->_willShow[] = 'form'; $this->_willShow[] = 'formAdd'; } if ($this->getParam('edit')) { $this->_willShow[] = 'form'; $this->_willShow[] = 'formEdit'; } } else { if ($this->getParam('detail') || $this->getParam('delete') ){ $this->_willShow[] = 'detail'; } else { $this->_willShow[] = 'listing'; } } }}
- Factory pattern in Zend data grid
- Data Grid in Zend
- Factory design pattern in java
- Understanding and Implementing Factory Pattern in C++
- Display Sum Total in Data Grid
- Distributed Data Management in Grid Environments
- Data Mining in Grid Computing Environments
- A Generic Data Access Component using Factory Pattern
- Factory Pattern
- Factory Pattern
- Factory Pattern
- Factory Pattern
- Factory Pattern
- Factory Pattern
- Factory Pattern
- Factory Pattern
- Factory Pattern
- Factory Pattern
- 包图
- BAPI_ACC_DOCUMENT_POST,如何处理没有的参数传入系统
- 7、面向对象之封装
- 深入浅出之正则表达式(二)
- 350. Out of office, out of danger. 无官一身轻
- Factory pattern in Zend data grid
- 序列图
- 2012-12-11集结号【创赢操盘】周二股市策略
- Myeclipse优化
- 一条网线,不用路由器,多台笔记本电脑共享上网
- Custom shipping method in Magento
- 每次开机检测硬盘
- CentOS用户和组管理
- sp_addlinkedserver 多数据库操作 link 的创建,删除,查看