Files
majestic/Config.php

40 lines
885 B
PHP
Raw Normal View History

2014-06-02 18:58:49 +04:00
<?php namespace Majestic;
/**
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage Model
* @since 2010-02-17
*/
2014-05-27 17:56:46 +04:00
2014-06-02 18:58:49 +04:00
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);
}
}
2014-05-27 17:56:46 +04:00
class ConfigArray extends \ArrayObject
{
public function __construct($array)
{
2014-05-27 17:56:46 +04:00
parent::__construct($array, \ArrayObject::ARRAY_AS_PROPS);
}
public function offsetGet($index)
{
if (!$this->offsetExists($index)) {
2014-06-02 18:58:49 +04:00
throw new Exception\GeneralException('Configuration variable "' . $index . '" undefined');
}
return parent::offsetGet($index);
}
}