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.

39 lines
876 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. namespace Majestic;
  10. class Config extends \Registry
  11. {
  12. private static $_class_name = 'Config';
  13. static public function set($name, $value)
  14. {
  15. if (is_array($value)) {
  16. $value = new ConfigArray($value);
  17. }
  18. self::getInstance()->offsetSet($name, $value);
  19. }
  20. }
  21. class ConfigArray extends \ArrayObject
  22. {
  23. public function __construct($array)
  24. {
  25. parent::__construct($array, \ArrayObject::ARRAY_AS_PROPS);
  26. }
  27. public function offsetGet($index)
  28. {
  29. if (!$this->offsetExists($index)) {
  30. throw new \GeneralException('Configuration variable "' . $index . '" undefined');
  31. }
  32. return parent::offsetGet($index);
  33. }
  34. }