getClassMetadataFor() публичный Метод

public getClassMetadataFor ( $class ) : NodeEntityMetadata
$class
Результат GraphAware\Neo4j\OGM\Metadata\NodeEntityMetadata
Пример #1
0
 public function setInversedAssociation($baseInstance, $otherInstance, $relationshipKey)
 {
     $class = get_class($otherInstance);
     if (false !== get_parent_class($otherInstance)) {
         $class = get_parent_class($otherInstance);
     }
     $assoc = $this->classMetadata->getRelationship($relationshipKey);
     if ($assoc->hasMappedByProperty()) {
         $mappedBy = $assoc->getMappedByProperty();
         $reflClass = $this->getReflectionClass($class);
         $property = $reflClass->getProperty($mappedBy);
         $property->setAccessible(true);
         $otherClassMetadata = $this->entityManager->getClassMetadataFor(get_class($otherInstance));
         if ($otherClassMetadata instanceof RelationshipMetadata || $otherClassMetadata instanceof RelationshipEntityMetadata) {
             return;
         }
         if ($otherClassMetadata->getRelationship($mappedBy)->isCollection()) {
             if (null === $property->getValue($otherInstance)) {
                 $mt = $otherClassMetadata->getRelationship($mappedBy);
                 $lazy = new LazyRelationshipCollection($this->entityManager, $otherInstance, $mt->getTargetEntity(), $mt, $baseInstance);
                 $property->setValue($otherInstance, $lazy);
             } else {
                 $property->getValue($otherInstance)->addInit($baseInstance);
             }
         } else {
             $property->setValue($otherInstance, $baseInstance);
         }
     }
 }
Пример #2
0
 /**
  * @param $class
  *
  * @return Persister\EntityPersister
  */
 public function getPersister($class)
 {
     if (!array_key_exists($class, $this->persisters)) {
         $classMetadata = $this->entityManager->getClassMetadataFor($class);
         $this->persisters[$class] = new EntityPersister($class, $classMetadata);
     }
     return $this->persisters[$class];
 }