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