예제 #1
0
 /**
  *  Set a namespace for all connections is it is called
  *  statically from ActiveMongo or for specific classes
  *  if it is called from an instance.
  *
  *  @param string $namespace
  *
  *  @return bool
  */
 static final function setNamespace($namespace = '')
 {
     if (preg_match("#^[\\-\\_a-z0-9]*\$#i", $namespace)) {
         /* sort of standard late binding */
         if (isset($this)) {
             $context = get_class($this);
         } else {
             $context = get_called_class();
         }
         if ($context == __CLASS__ || self::isAbstractChildClass($context)) {
             self::$_namespace = $namespace;
         } else {
             self::$_namespaces[$context] = $namespace;
         }
         return TRUE;
     }
     return FALSE;
 }