示例#1
0
文件: Registry.php 项目: hjr3/titon
 /**
  * Manually store an object into registry, and store the object name to the $__mapping array.
  * The property $__registered contains the object where as $__mapping is just the class name.
  *
  * @access public
  * @param object $object
  * @param string $slug
  * @return object
  * @static
  */
 public static function store($object, $slug = null)
 {
     if (!is_object($object)) {
         throw new Exception('The object passed must be instantiated.');
     }
     $namespace = get_class($object);
     $className = App::baseClass($namespace);
     if (!$slug) {
         $slug = App::toDotNotation($namespace);
     }
     static::$__registered[$slug] = $object;
     static::$__mapping = Set::insert(static::$__mapping, $slug, $className);
     return $object;
 }