Example #1
0
 /**
  *
  * @param string $className
  * @return Miao_Form_Controller
  */
 protected static function _getInstance($className)
 {
     $index = 'frm::' . $className;
     if (!Miao_Registry::isRegistered($index)) {
         $instance = new $className();
         Miao_Registry::set($index, $instance);
     }
     return $instance;
 }
Example #2
0
 public static function register(array $config)
 {
     $map = array();
     foreach ($config['libs'] as $item) {
         $map[$item['name']] = $item['path'];
     }
     $index = self::$_defaultindex;
     $result = new Miao_Path($config['project_root'], $config['main_config_filename'], $map);
     Miao_Registry::set($index, $result);
 }
Example #3
0
 protected static function _getInstance($className)
 {
     $index = 'dh:' . $className;
     if (Miao_Registry::isRegistered($index)) {
         $result = Miao_Registry::get($index);
     } else {
         $result = new $className();
         Miao_Registry::set($index, $result);
     }
     return $result;
 }
Example #4
0
 private static function _getDefaultInstance()
 {
     $index = 'Miao_Config::default';
     if (!Miao_Registry::isRegistered($index)) {
         $result = new self();
         Miao_Registry::set($index, $result);
     } else {
         $result = Miao_Registry::get($index);
     }
     return $result;
 }
Example #5
0
 protected static function _getInstance($className)
 {
     $index = 'dh:jscsslist:' . $className;
     $result = null;
     if (!Miao_Registry::isRegistered($index)) {
         $result = new $className();
         if (!$result instanceof Miao_Office_DataHelper_Url) {
             throw new Miao_Office_DataHelper_Url_Exception(sprintf('Invalid class %s: must be instance of Miao_Office_DataHelper_Url', $className));
         }
         if (!$result instanceof Miao_Office_DataHelper_Url_Interface) {
             throw new Miao_Office_DataHelper_Url_Exception(sprintf('Invalid class %s: must be implement of Miao_Office_DataHelper_Url_Interface', $className));
         }
         Miao_Registry::set($index, $result);
     } else {
         $result = Miao_Registry::get($index);
     }
     return $result;
 }
Example #6
0
 public function testRegistryGet()
 {
     Miao_Registry::set('foo', 'bar');
     $bar = Miao_Registry::get('foo');
     $this->assertEquals('bar', $bar);
 }