Files
majestic/Config.php
pzinovkin d6b0a9d37d Registry, ViewHelperHead added, Config now inherited from Registry, #16
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@130 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
2010-03-16 14:47:06 +00:00

40 lines
887 B
PHP

<?php
/**
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage Model
* @since 2010-02-17
* @version SVN: $Id$
* @filesource $URL$
*/
class Config extends Registry
{
private static $_class_name = 'Config';
static public function set($name, $value)
{
if (is_array($value)) {
$value = new ConfigArray($value);
}
self::getInstance()->offsetSet($name, $value);
}
}
class ConfigArray extends ArrayObject
{
public function __construct($array)
{
parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
}
public function offsetGet($index)
{
if (!$this->offsetExists($index)) {
throw new Exception('Configuration variable "' . $index . '" undefined');
}
return parent::offsetGet($index);
}
}