From 1499738085c1bb06fcc6c287ed46b01672b49d51 Mon Sep 17 00:00:00 2001 From: vinnl Date: Tue, 4 Mar 2008 18:07:40 +0100 Subject: [PATCH] Little refactoring of Install Module, created Pivip_Db_Table_Abstract. --- project/library/Pivip/Db/Table/Abstract.php | 45 ++++++++++++++++++++++ .../install/controllers/InstallController.php | 18 +++++++++ .../install/{index.phtml => configuration.phtml} | 0 .../library/Pivip/Db/Table/TableModelsSpec.php | 20 ++++++++++ 4 files changed, 83 insertions(+) create mode 100644 project/library/Pivip/Db/Table/Abstract.php rename project/modules/install/views/scripts/install/{index.phtml => configuration.phtml} (100%) create mode 100644 specifications/library/Pivip/Db/Table/TableModelsSpec.php diff --git a/project/library/Pivip/Db/Table/Abstract.php b/project/library/Pivip/Db/Table/Abstract.php new file mode 100644 index 0000000..910b8b7 --- /dev/null +++ b/project/library/Pivip/Db/Table/Abstract.php @@ -0,0 +1,45 @@ + + */ + +/** + * Database table model + */ +class Pivip_Db_Table_Abstract extends Zend_Db_Table_Abstract +{ + /** + * If no name is set, set the table name to a lowercase version of the class + * + * @param mixed $config Array of configuration options or a DB Adapter + */ + public function __construct($config = array()) + { + if(null === $this->_name) + { + $this->_name = strtolower(get_class($this)); + } + parent::__construct($config); + } +} \ No newline at end of file diff --git a/project/modules/install/controllers/InstallController.php b/project/modules/install/controllers/InstallController.php index 5bd2f14..b31a8ca 100644 --- a/project/modules/install/controllers/InstallController.php +++ b/project/modules/install/controllers/InstallController.php @@ -35,6 +35,24 @@ class Install_InstallController extends Pivip_Controller_Module_Abstract */ public function indexAction() { + switch($this->_request->getParam('phase')) + { + default: + $this->_forward('configuration', 'install', 'install', + $this->_request->getParams()); + break; + } + } + + /** + * Manage configuration of Pivip + * + * Displays a form that lets the administrator enter new configuration + * values and, when that form is submitted, writes the new configuration data + * to disk and redirects to the next step. + */ + public function configurationAction() + { $route = Zend_Controller_Front::getInstance()->getRouter() ->getRoute('install'); $action = $route->assemble(array('phase' => 'configure')); diff --git a/project/modules/install/views/scripts/install/index.phtml b/project/modules/install/views/scripts/install/configuration.phtml similarity index 100% rename from project/modules/install/views/scripts/install/index.phtml rename to project/modules/install/views/scripts/install/configuration.phtml diff --git a/specifications/library/Pivip/Db/Table/TableModelsSpec.php b/specifications/library/Pivip/Db/Table/TableModelsSpec.php new file mode 100644 index 0000000..deeeaf2 --- /dev/null +++ b/specifications/library/Pivip/Db/Table/TableModelsSpec.php @@ -0,0 +1,20 @@ +spec($fakeModel->getName)->should()->beEqualTo('faketable'); + } +} + +class FakeTable extends Pivip_Db_Table_Abstract +{ + public function getName() + { + return $this->_name; + } +} \ No newline at end of file -- 2.11.4.GIT