/**
  * Resolves a registered namespace alias to the full namespace.
  *
  * @param string $documentNamespaceAlias
  *
  * @return string
  * @throws ODMOrientDbException
  */
 public function getDocumentNamespace($documentNamespaceAlias)
 {
     if (!isset($this->_attributes['documentNamespaces'][$documentNamespaceAlias])) {
         throw ODMOrientDbException::unknownDocumentNamespace($documentNamespaceAlias);
     }
     return trim($this->_attributes['documentNamespaces'][$documentNamespaceAlias], '\\');
 }
Example #2
0
 /**
  * @param object $document
  * @param array  $visited
  *
  * @throws ODMOrientDbException
  */
 private function doRemove($document, array &$visited)
 {
     $oid = spl_object_hash($document);
     if (isset($visited[$oid])) {
         return;
         // Prevent infinite recursion
     }
     $visited[$oid] = $document;
     // mark visited
     /* Cascade first, because scheduleForDelete() removes the entity from
      * the identity map, which can cause problems when a lazy Proxy has to
      * be initialized for the cascade operation.
      */
     $this->cascadeRemove($document, $visited);
     $class = $this->dm->getClassMetadata(get_class($document));
     $documentState = $this->getDocumentState($document);
     switch ($documentState) {
         case self::STATE_NEW:
         case self::STATE_REMOVED:
             // nothing to do
             break;
         case self::STATE_MANAGED:
             $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preRemove);
             if ($invoke !== ListenersInvoker::INVOKE_NONE) {
                 $this->listenersInvoker->invoke($class, Events::preRemove, $document, new LifecycleEventArgs($document, $this->dm), $invoke);
             }
             $this->scheduleForDelete($document);
             break;
         case self::STATE_DETACHED:
             throw ODMOrientDbException::detachedDocumentCannotBeRemoved();
         default:
             throw ODMOrientDbException::invalidDocumentState($documentState);
     }
 }