Working to get installation working smootly.
[pivip.git] / project / library / Pivip / Module / Abstract.php
blob9234e8babcc251a8dc7c2aa0e1e24c143cc89ae4
1 <?php
3 /**
4 * Pivip
5 * Copyright (C) 2008 Vincent Tunru
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 * @license http://www.fsf.org/licensing/licenses/info/GPLv2.html GPL v.2
21 * @category Pivip
22 * @package Pivip_Install
23 * @copyright (C) 2008 Vincent Tunru
24 * @author Vincent Tunru <email@vincentt.org>
27 /**
28 * Modules can extend this to provide an interface to the module
30 abstract class Pivip_Module_Abstract
32 /**
33 * A list of required modules and their versions
35 * The module should define minimum and maximum versions, using
36 * array('module' => array('min' => 0.0.0dev', 'max' => '3.1.1'));
38 * @var array
40 protected $_dependencies;
42 /**
43 * Modules must be able to determine whether they're installed
45 * If a module does not need to be installed, this function should return
46 * true by default.
48 * @return boolean True if the module is already installed, flase if not.
50 abstract public static function isInstalled();
52 /**
53 * Whether a module needs configuration before installation
55 * Note: if modules return true, they also need to provide a
56 * configure() function.
58 * @return boolean Whether the module needs to be configured.
60 abstract public static function needsConfiguring();
62 /**
63 * Install the module (prepare the database, mark installed status, ...)
65 * @throws Pivip_Install_Exception
66 * @return boolean Whether the installation succeeded
68 public function install()
72 /**
73 * Uninstall the module (remove database values, ...)
75 * @throws Pivip_Install_Exception
76 * @return boolean Whether uninstallation succeeded
78 public function uninstall()
82 /**
83 * Check whether the module's API dependencies are available
85 * @throws Pivip_Install_Exception
86 * @return boolean True if API dependencies are met.
88 public function checkDependencies()
92 /**
93 * Load the module
95 public function bootstrap()
99 /**
100 * Allows child classes to push a request onto the stack
102 * @param Zend_Controller_Request_Abstract $request The request to push.
104 protected static function _pushStack(Zend_Controller_Request_Abstract $request)
106 $frontController = Zend_Controller_Front::getInstance();
107 $actionStack = $frontController
108 ->getPlugin('Zend_Controller_Plugin_ActionStack');
109 if(!$actionStack)
111 $actionStack = new Zend_Controller_Plugin_ActionStack();
112 $frontController->registerPlugin($actionStack);
114 $actionStack->pushStack($request);