Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function createProxyDefinition($className)
 {
     /** @var ClassMetadata $classMetadata */
     $classMetadata = $this->metadataFactory->getMetadataFor($className);
     $documentPersister = $this->uow->getDocumentPersister($className);
     $reflectionFields = $classMetadata->getReflectionProperties();
     $reflectionId = $reflectionFields[$classMetadata->getRidPropertyName()];
     return new ProxyDefinition(ClassUtils::generateProxyClassName($className, $this->proxyNamespace), $classMetadata->getIdentifierFieldNames(), $reflectionFields, $this->createInitializer($classMetadata, $documentPersister, $reflectionId), $this->createCloner($classMetadata, $documentPersister, $reflectionId));
 }
 /**
  * Gets the commit order for all the classes available via the provided {@see ClassMetadataFactory}
  *
  * @param ClassMetadataFactory $mdf
  *
  * @return \string[]
  */
 public static function getCommitOrderFromMetadata(ClassMetadataFactory $mdf)
 {
     $cd = $mdf->getCacheDriver();
     if ($cd->contains(self::CACHE_KEY)) {
         return $cd->fetch(self::CACHE_KEY);
     }
     $co = new self();
     /** @var ClassMetadata $class */
     foreach ($mdf->getAllMetadata() as $class) {
         $co->classes[$class->name] = $class;
         foreach ($class->associationMappings as $assoc) {
             if (!isset($assoc['reference']) || !isset($assoc['targetDoc'])) {
                 continue;
             }
             /** @var ClassMetadata $dependency */
             $dependency = $mdf->getMetadataFor($assoc['targetDoc']);
             if (!$co->hasDependency($dependency, $class)) {
                 $co->addDependency($dependency, $class);
             }
             // If the target class has mapped subclasses, these share the same dependency.
             //                if ( ! $targetClass->subClasses) {
             //                    continue;
             //                }
             //
             //                foreach ($targetClass->subClasses as $subClassName) {
             //                    $targetSubClass = $this->dm->getClassMetadata($subClassName);
             //
             //                    if ( ! $calc->hasClass($subClassName)) {
             //                        $calc->addClass($targetSubClass);
             //
             //                        $newNodes[] = $targetSubClass;
             //                    }
             //
             //                    $calc->addDependency($targetSubClass, $class);
             //                }
         }
     }
     $ordered = $co->getCommitOrder();
     $cd->save(self::CACHE_KEY, $ordered);
     return $ordered;
 }
 private function getDocReference($ref)
 {
     $oid = spl_object_hash($ref);
     if (isset($this->references[$oid])) {
         return $this->references[$oid];
     }
     /** @var ClassMetadata $rmd */
     $rmd = $this->metadataFactory->getMetadataFor(get_class($ref));
     $rid = $rmd->getIdentifierValue($ref);
     if ($rid === null) {
         throw new ODMOrientDbException('missing reference');
     }
     static $rid_type;
     if (!isset($rid_type)) {
         $rid_type = Type::getType('rid');
     }
     return $rid_type->convertToDatabaseValue($rid);
 }
 /**
  * Gets the $class Metadata.
  *
  * @param   string $class
  *
  * @return \Doctrine\ODM\OrientDB\Mapping\ClassMetadata
  */
 public function getClassMetadata($class)
 {
     return $this->metadataFactory->getMetadataFor($class);
 }