GraphAware\Neo4j\OGM\EntityManager::getClassMetadataFor PHP Метод

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

public getClassMetadataFor ( $class ) : NodeEntityMetadata
$class
Результат GraphAware\Neo4j\OGM\Metadata\NodeEntityMetadata
    public function getClassMetadataFor($class)
    {
        if (!array_key_exists($class, $this->loadedMetadata)) {
            $this->loadedMetadata[$class] = $this->metadataFactory->create($class);
        }
        return $this->loadedMetadata[$class];
    }

Usage Example

Пример #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);
         }
     }
 }
All Usage Examples Of GraphAware\Neo4j\OGM\EntityManager::getClassMetadataFor