Source for file Config.php
Documentation is available at Config.php
* Copyright (C) 2009 Mai (Me Artificial Intelligence)
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* @author Wouter Bulten (wouterbulten@mai-ai.org)
* @copyright Copyright (C) 2009 Mai (Me Artificial Intelligence)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
* @link http://www.launchpad.net/mai
* This require_once statement is always executed unless Mai::$_autoloader is defined true.
* After creation of this class the value of the config.ini file is used.
//Zend_Config_Ini is needed to extend.
require_once 'Zend/Config/Ini.php';
* Mai_Config holds the config of Mai.
* @author Wouter Bulten (wouterbulten@mai-ai.org)
* @copyright Copyright (C) 2009 Mai (Me Artificial Intelligence)
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
* @link http://www.launchpad.net/mai
* @var Mai_Config Singleton instance
protected static $_instance;
* @var string Location of the config file relative to the base dir.
protected static $_iniFile = '/Mai/Config/Files/config.ini';
* Mai_Config can only be created by itself. Starts up the parent constructor.
public function __construct($creator, $filename, $section, $options)
//Instanceof cannot be used because Mai_Config has to create itself.
if($creator !== 'Mai_Config')
parent::__construct($filename, $section, $options);
* Retrieve singleton instance
//Make sure that this class can only be used if Mai is running
if(!Mai::isInit() && !($class instanceof Mai) && self::$_instance === null)
trigger_error('Mai has not been setup yet. Please use Mai::init().', E_USER_ERROR);
if (null === self::$_instance) {
//Start up and load ini file
$envName = Mai::$_envNames[Mai::getEnv()];
self::$_instance = new self(__CLASS__ , Mai::baseDir() . self::$_iniFile, $envName, array());
* Use to get variables form the ini file. Acts the same as getInstance()
public static function getVar()
return self::getInstance();
* Cloning of a singleton class is not allowed.
* Function to prevent deserializing
|