You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
851 B

  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage Model
  7. * @since 2010-02-17
  8. */
  9. class Config extends Registry
  10. {
  11. private static $_class_name = 'Config';
  12. static public function set($name, $value)
  13. {
  14. if (is_array($value)) {
  15. $value = new ConfigArray($value);
  16. }
  17. self::getInstance()->offsetSet($name, $value);
  18. }
  19. }
  20. class ConfigArray extends ArrayObject
  21. {
  22. public function __construct($array)
  23. {
  24. parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
  25. }
  26. public function offsetGet($index)
  27. {
  28. if (!$this->offsetExists($index)) {
  29. throw new GeneralException('Configuration variable "' . $index . '" undefined');
  30. }
  31. return parent::offsetGet($index);
  32. }
  33. }