Registry
[
class tree: Registry
] [
index: Registry
] [
all elements
]
Packages:
Analyzer
Base
Cache
Config
Container
Creator
Log
Memory
Pattern
Registry
Stat
Word
Source for file Registry.php
Documentation is available at
Registry.php
<?php
/**
* Mai_Registry
*
* 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
*
*
@category
Mai
*
@package
Registry
*/
/** Required files */
if
(
!
Mai
::
getAutoloader
(
))
{
//Zend_Registry is needed to extend.
require_once
'Zend/Registry.php'
;
}
/**
* Mai_Registry acts as the registry for 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
*
*
@category
Mai
*
@package
Registry
*
@uses
Zend_Config_Ini
*/
class
Mai_Registry
extends
Zend_Registry
{
/**
*
@var
Mai_Registry
Singleton instance
*/
protected
static
$_instance
;
/**
*
@var
string
Location of the config file relative to the base dir.
*/
protected
static
$_iniFile
=
'/Config/Files/config.ini'
;
/**
* Set default values.
*
@return
void
*/
function
__construct
(
$creator
)
{
//Instanceof cannot be used because Mai_Registry has to create itself.
if
(
$creator
!==
'Mai_Registry'
)
{
trigger_error
(
'Mai_Registry is a singleton class.'
,
E_USER_ERROR
)
;
}
self
::
set
(
'output'
,
Mai_Config
::
getVar
(
)
->
output
->
default
)
;
parent
::
__construct
(
)
;
}
/**
* Retrieve singleton instance
*
*
@return
Mai_Registry
*/
public
static
function
getInstance
(
$class
=
null
)
{
//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
)
{
self
::
$_instance
=
new
self
(
__CLASS__
)
;
}
return
self
::
$_instance
;
}
/**
* Cloning of a singleton class is not allowed.
*
@return
void
*/
final
public
function
__clone
(
)
{
trigger_error
(
'Clone is not allowed.'
,
E_USER_ERROR
)
;
}
/**
* Function to prevent deserializing
*
@return
void
*/
public
function
__wakeup
(
)
{
trigger_error
(
'Deserializing is not allowed.'
,
E_USER_ERROR
)
;
}
}
Documentation generated on Mon, 27 Jul 2009 19:55:12 +0200 by
phpDocumentor 1.4.1