Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2. $conf = array (
  3. 'parts' => array(
  4. 'contr' => 'app/Controller',
  5. 'mod' => 'app/model/mod_main.php'
  6. ),
  7. 'что - то др.' => array(
  8. '' => '',
  9. '' => '',
  10. '' => ''
  11. )
  12. );
  13.  
  14.  
  15. class Registry {
  16. public static $obj = array();
  17.  
  18. protected static $instance;
  19.  
  20. protected function __construct() {
  21. global $conf;
  22. foreach ($conf['parts'] as $name => $parts) {
  23. self::$obj[$name] = new $parts;
  24. }
  25. }
  26.  
  27. public static function instance () {
  28. if(self::$instance === null) self::$instance = new self;
  29. return self::$instance;
  30. }
  31.  
  32. public function __set($name, $obj) {
  33. if (!isset(self::$obj[$name])) self::$obj[$name] = new $obj;
  34. }
  35.  
  36. public function __get($name) {
  37. if (is_object(self::$obj($name))) return self::$obj($name);
  38. }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement