Load the metadata for the specified class into the provided container.

@param string        $className
@param ClassMetadata $metadata
509339
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        $metadataFactory = $this->getObjectManager()->getMetadataFactory();
        $builder = new ClassMetadataBuilder($metadata);

        // Get the entity this entity audits
        $metadataClassName = $metadata->getName();
        $metadataClass = new $metadataClassName();
        $auditedClassName = $metadataClass->getAuditedEntityClass();

        $auditedClassMetadata = $metadataFactory->getMetadataFor($auditedClassName);
        $auditedClassName = $metadataClass->getAuditedEntityClass();

        // Is the passed class name a regular entity?
        if (! $this->getEntityConfigCollection()->containsKey($auditedClassName)) {
            return false;
        }

        // Add primary key
        $primaryKey = $builder->createField('_id', 'bigint')
            ->makePrimaryKey()
            ->generatedValue()
            ->unique()
            ->columnName('_id')
            ->build()
            ;

        $association = $builder->createManyToOne('revisionEntity', Entity\RevisionEntity::class);
        $association->build();

        // Add fields from target to audit entity
        foreach ($auditedClassMetadata->getFieldNames() as $fieldName) {
            $builder->addField(
                $fieldName,
                $auditedClassMetadata->getTypeOfField($fieldName),
                [
                    'columnName' => $auditedClassMetadata->getColumnName($fieldName),
                    'nullable' => true,
                    'quoted' => true
                ]
            );
        }

        foreach ($auditedClassMetadata->getAssociationMappings() as $mapping) {
            if (! $mapping['isOwningSide'] || isset($mapping['joinTable'])) {
                continue;
            }

            if (isset($mapping['joinTableColumns'])) {
                foreach ($mapping['joinTableColumns'] as $field) {
                    // FIXME:  set data type correct for mapping info
                    $builder->addField(
                        $mapping['fieldName'],
                        'bigint',
                        ['nullable' => true, 'columnName' => $field]
                    );
                }
            } elseif (isset($mapping['joinColumnFieldNames'])) {
                foreach ($mapping['joinColumnFieldNames'] as $field) {
                    // FIXME:  set data type correct for mapping info
                    $builder->addField(
                        $mapping['fieldName'],
                        'bigint',
                        ['nullable' => true, 'columnName' => $field]
                    );
                }
            } else {
                throw new Exception('Unhandled association mapping');
            }
        }

        $metadata->setTableName(
            $this->getAuditOptions()->getAuditTableNamePrefix()
                . $auditedClassMetadata->getTableName()
                . $this->getAuditOptions()->getAuditTableNameSuffix()
        );

        return;
    }
1323352
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        $class = $metadata->getReflectionClass();
        if (! $class) {
            // this happens when running annotation driver in combination with
            // static reflection services. This is not the nicest fix
            $class = new \ReflectionClass($metadata->name);
        }

        $entityAnnot = $this->reader->getClassAnnotation($class, 'Doctrine\KeyValueStore\Mapping\Annotations\Entity');
        if (! $entityAnnot) {
            throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
        }
        $metadata->storageName = $entityAnnot->storageName;

        // Evaluate annotations on properties/fields
        foreach ($class->getProperties() as $property) {
            $idAnnot        = $this->reader->getPropertyAnnotation(
                $property,
                'Doctrine\KeyValueStore\Mapping\Annotations\Id'
            );
            $transientAnnot = $this->reader->getPropertyAnnotation(
                $property,
                'Doctrine\KeyValueStore\Mapping\Annotations\Transient'
            );
            if ($idAnnot) {
                $metadata->mapIdentifier($property->getName());
            } elseif ($transientAnnot) {
                $metadata->skipTransientField($property->getName());
            } else {
                $metadata->mapField(['fieldName' => $property->getName()]);
            }
        }
    }
1021673
protected function loadTranslatableMetadata($className, $config)
    {
        if (! isset($config[$className])
            || ! isset($config[$className]['prezent'])
            || ! array_key_exists('translatable', $config[$className]['prezent'])
        ) {
            return;
        }

        $classMetadata = new TranslatableMetadata($className);

        $translatable = $config[$className]['prezent']['translatable'] ?: array();

        $propertyMetadata = new PropertyMetadata(
            $className,
            // defaults to translatable
            isset($translatable['field']) ? $translatable['field'] : 'translations'
        );

        // default targetEntity
        $targetEntity = $className . 'Translation';

        $classMetadata->targetEntity = isset($translatable['targetEntity']) ? $translatable['targetEntity']: $targetEntity;
        $classMetadata->translations = $propertyMetadata;
        $classMetadata->addPropertyMetadata($propertyMetadata);

        if (isset($translatable['currentLocale'])) {
            $propertyMetadata = new PropertyMetadata($className, $translatable['currentLocale']);

            $classMetadata->currentLocale = $propertyMetadata;
            $classMetadata->addPropertyMetadata($propertyMetadata);
        }

        if (isset($translatable['fallbackLocale'])) {
            $propertyMetadata = new PropertyMetadata($className, $translatable['fallbackLocale']);

            $classMetadata->fallbackLocale = $propertyMetadata;
            $classMetadata->addPropertyMetadata($propertyMetadata);
        }

        return $classMetadata;
    }
389287
public function getMetadataForClass($className)
    {
        if (isset($this->loadedMetadata[$className])) {
            return $this->filterNullMetadata($this->loadedMetadata[$className]);
        }

        $metadata = null;
        /** @var \ReflectionClass $class */
        foreach ($this->getClassHierarchy($className) as $class) {
            if ($class->isAbstract()) {
                continue;
            }
            if (isset($this->loadedClassMetadata[$name = $class->getName()])) {
                if (null !== $classMetadata = $this->filterNullMetadata($this->loadedClassMetadata[$name])) {
                    $this->addClassMetadata($metadata, $classMetadata);
                }
                continue;
            }

            // check the cache
            if (null !== $this->cache) {
                /** @var ClassMetadata $classMetadata */
                if (($classMetadata = $this->cache->loadClassMetadataFromCache($class)) instanceof NullMetadata) {
                    $this->loadedClassMetadata[$name] = $classMetadata;
                    continue;
                }

                if (null !== $classMetadata) {
                    if ( ! $classMetadata instanceof ClassMetadata) {
                        throw new \LogicException(sprintf('The cache must return instances of ClassMetadata, but got %s.', var_export($classMetadata, true)));
                    }

                    if ($this->debug && !$classMetadata->isFresh()) {
                        $this->cache->evictClassMetadataFromCache($classMetadata->reflection);
                    } else {
                        $this->loadedClassMetadata[$name] = $classMetadata;
                        $this->addClassMetadata($metadata, $classMetadata);
                        continue;
                    }
                }
            }

            // load from source
            if (null !== $classMetadata = $this->driver->loadMetadataForClass($class)) {
                $this->loadedClassMetadata[$name] = $classMetadata;
                $this->addClassMetadata($metadata, $classMetadata);

                if (null !== $this->cache) {
                    $this->cache->putClassMetadataInCache($classMetadata);
                }

                continue;
            }

            if (null !== $this->cache && !$this->debug) {
                $this->cache->putClassMetadataInCache(new NullMetadata($class->getName()));
            }
        }

        if (null === $metadata) {
            $metadata = new NullMetadata($className);
        }

        return $this->filterNullMetadata($this->loadedMetadata[$className] = $metadata);
    }
595298
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        $reflClass = $metadata->getReflectionClass();

        $documentAnnots = [];
        foreach ($this->reader->getClassAnnotations($reflClass) as $annot) {
            foreach ($this->entityAnnotationClasses as $annotClass => $i) {
                if ($annot instanceof $annotClass) {
                    $documentAnnots[$i] = $annot;
                }
            }
        }
        if (!$documentAnnots) {
            throw MappingException::classIsNotAValidDocument($className);
        }

        // find the winning document annotation
        ksort($documentAnnots);

        $documentAnnot = reset($documentAnnots);

        if ($documentAnnot instanceof ODM\MappedSuperclass) {
            $metadata->isMappedSuperclass = true;
        }
        if (null !== $documentAnnot->referenceable) {
            $metadata->setReferenceable($documentAnnot->referenceable);
        }

        if (null !== $documentAnnot->versionable) {
            $metadata->setVersioned($documentAnnot->versionable);
        }

        if (null !== $documentAnnot->uniqueNodeType) {
            $metadata->setUniqueNodeType($documentAnnot->uniqueNodeType);
        }

        if (null !== $documentAnnot->mixins) {
            $metadata->setMixins($documentAnnot->mixins);
        }

        if (null !== $documentAnnot->inheritMixins) {
            $metadata->setInheritMixins($documentAnnot->inheritMixins);
        }

        if (null !== $documentAnnot->nodeType) {
            $metadata->setNodeType($documentAnnot->nodeType);
        }

        if (null !== $documentAnnot->repositoryClass) {
            $metadata->setCustomRepositoryClassName($documentAnnot->repositoryClass);
        }

        if (null !== $documentAnnot->translator) {
            $metadata->setTranslator($documentAnnot->translator);
        }

        if ([] !== $documentAnnot->childClasses) {
            $metadata->setChildClasses($documentAnnot->childClasses);
        }

        $metadata->setIsLeaf($documentAnnot->isLeaf);

        foreach ($reflClass->getProperties() as $property) {
            if ($metadata->isInheritedField($property->name)
                && $metadata->name !== $property->getDeclaringClass()->getName()
            ) {
                continue;
            }

            $mapping = [];
            $mapping['fieldName'] = $property->getName();

            foreach ($this->reader->getPropertyAnnotations($property) as $fieldAnnot) {
                if ($fieldAnnot instanceof ODM\Property) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapField($mapping);
                } elseif ($fieldAnnot instanceof ODM\Id) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapId($mapping);
                } elseif ($fieldAnnot instanceof ODM\Node) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapNode($mapping);
                } elseif ($fieldAnnot instanceof ODM\Nodename) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapNodename($mapping);
                } elseif ($fieldAnnot instanceof ODM\ParentDocument) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                    $metadata->mapParentDocument($mapping);
                } elseif ($fieldAnnot instanceof ODM\Child) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                    $metadata->mapChild($mapping);
                } elseif ($fieldAnnot instanceof ODM\Children) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                    $metadata->mapChildren($mapping);
                } elseif ($fieldAnnot instanceof ODM\ReferenceOne) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                    $metadata->mapManyToOne($mapping);
                } elseif ($fieldAnnot instanceof ODM\ReferenceMany) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                    $metadata->mapManyToMany($mapping);
                } elseif ($fieldAnnot instanceof ODM\Referrers) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $mapping['cascade'] = $this->getCascadeMode($fieldAnnot->cascade);
                    $metadata->mapReferrers($mapping);
                } elseif ($fieldAnnot instanceof ODM\MixedReferrers) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapMixedReferrers($mapping);
                } elseif ($fieldAnnot instanceof ODM\Locale) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapLocale($mapping);
                } elseif ($fieldAnnot instanceof ODM\Depth) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapDepth($mapping);
                } elseif ($fieldAnnot instanceof ODM\VersionName) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapVersionName($mapping);
                } elseif ($fieldAnnot instanceof ODM\VersionCreated) {
                    $mapping = array_merge($mapping, (array) $fieldAnnot);
                    $metadata->mapVersionCreated($mapping);
                }
            }
        }

        foreach ($reflClass->getMethods() as $method) {
            if ($method->isPublic() && $method->getDeclaringClass()->getName() == $metadata->name) {
                foreach ($this->reader->getMethodAnnotations($method) as $annot) {
                    if ($annot instanceof ODM\PrePersist) {
                        $metadata->addLifecycleCallback($method->getName(), Event::prePersist);
                    } elseif ($annot instanceof  ODM\PostPersist) {
                        $metadata->addLifecycleCallback($method->getName(), Event::postPersist);
                    } elseif ($annot instanceof ODM\PreUpdate) {
                        $metadata->addLifecycleCallback($method->getName(), Event::preUpdate);
                    } elseif ($annot instanceof ODM\PostUpdate) {
                        $metadata->addLifecycleCallback($method->getName(), Event::postUpdate);
                    } elseif ($annot instanceof ODM\PreRemove) {
                        $metadata->addLifecycleCallback($method->getName(), Event::preRemove);
                    } elseif ($annot instanceof ODM\PostRemove) {
                        $metadata->addLifecycleCallback($method->getName(), Event::postRemove);
                    } elseif ($annot instanceof  ODM\PostLoad) {
                        $metadata->addLifecycleCallback($method->getName(), Event::postLoad);
                    }
                }
            }
        }

        $metadata->validateClassMapping();
    }
1280692
public function loadMetadataForClass($className, CommonClassMetadata $metadata)
    {
        try {
            $xmlRoot = $this->getElement($className);
        } catch (MappingException $exception) {
            throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
        }

        if ($xmlRoot->getName() != 'entity') {
            throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.');
        }

        $class = new \ReflectionClass($className);

        if (isset($xmlRoot['storage-name'])) {
            $metadata->storageName = $xmlRoot['storage-name'];
        }

        $ids = [];
        if (isset($xmlRoot->id)) {
            foreach ($xmlRoot->id as $id) {
                $ids[] = (string) $id;
            }
        }

        $transients = [];
        if (isset($xmlRoot->transient)) {
            foreach ($xmlRoot->transient as $transient) {
                $transients[] = (string) $transient;
            }
        }

        foreach ($class->getProperties() as $property) {
            if (in_array($property->getName(), $ids)) {
                $metadata->mapIdentifier($property->getName());

                continue;
            }

            if (in_array($property->getName(), $transients)) {
                $metadata->skipTransientField($property->getName());

                continue;
            }

            $metadata->mapField([
                'fieldName' => $property->getName(),
            ]);
        }
    }
652310
public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addPropertyConstraint('contractNumber', new Assert\NotBlank());
        $metadata->addPropertyConstraint('contractNumber', new Assert\Type(array('type' => 'integer')));
        $metadata->addPropertyConstraint('contractNumber', new Assert\Regex(array('pattern' => '/^[0-9]{6}$/')));

        $metadata->addPropertyConstraint('password', new Assert\NotBlank());
        $metadata->addPropertyConstraint('password', new Assert\Type(array('type' => 'string')));

        $metadata->addPropertyConstraint('service', new Assert\NotBlank());
        $metadata->addPropertyConstraint('service', new Assert\Valid());

        $metadata->addPropertyConstraint('parcel', new Assert\NotBlank());
        $metadata->addPropertyConstraint('parcel', new Assert\Valid());

        $metadata->addPropertyConstraint('dest', new Assert\NotBlank());
        $metadata->addPropertyConstraint('dest', new Assert\Valid());

        $metadata->addPropertyConstraint('exp', new Assert\NotBlank());
        $metadata->addPropertyConstraint('exp', new Assert\Valid());
    }
146107
private function getOrCreateClassMetadataDefinition(string $className, ?ClassMetadata $parent) : ClassMetadataDefinition
    {
        if (! isset($this->definitions[$className])) {
            $this->definitions[$className] = $this->definitionFactory->build($className, $parent);
        }

        return $this->definitions[$className];
    }
1190974
public function loadClassMetadata(LoadClassMetadataEventArgs $args)
    {
        $metadata = $args->getClassMetadata();
        if ($metadata->name == 'Opifer\\EavBundle\\Entity\\Value') {
            $metadata->setDiscriminatorMap($this->getDiscriminatorMap());
        }
    }
152868
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $classMetadata = $eventArgs->getClassMetadata();
        if (MetadataLayer::isAlreadyProcessed($classMetadata)) {
            // we can skip it
            return;
        }

        $fieldNames = array_flip($classMetadata->getFieldNames());
        $reflectionClass = $classMetadata->getReflectionClass();

        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            if (isset($fieldNames[$reflectionProperty->getName()])) {
                $this->loadHubProperty($reflectionProperty, $classMetadata);
            } else {
                $this->loadMaskProperty($reflectionProperty, $classMetadata);
            }
        }
    }
1053680
public function loadClassMetadata(Mapping\ClassMetadataInterface $metadata)
    {
        
        $reflClass = $metadata->getReflectionClass();
        
        //Iterate over properties to get annotations
        foreach($reflClass->getProperties() as $property) {
            
            $this->readProperty($property, $metadata);
            
        }
        
    }
25550
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        /* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */
        $metadata->hasEncryptedProperties = false;
        $metadata->encryptedProperties = array();
        $class = $metadata->getReflectionClass();
        
        foreach ($class->getProperties() as $name => $property) {
            /** @var \Giftcards\Encryption\Doctrine\Configuration\Annotation\Encrypted $annotation */
            $annotation = $this->reader->getPropertyAnnotation(
                $property,
                'Giftcards\Encryption\Doctrine\Configuration\Annotation\Encrypted'
            );
            
            if (!$annotation) {
                continue;
            }
            $metadata->hasEncryptedProperties = true;
            $metadata->encryptedProperties[$property->getName()] = array(
                'profile' => $annotation->profile,
                'ignored_values' => $annotation->ignoredValues
            );
        }
    }
266646
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        foreach ($this->drivers as $driver) {
            if (in_array($className, $driver->getAllClassNames())) {
                return $driver->loadMetadataForClass($className, $metadata);
            }
        }
    }
1180034
public function getMetadataFor($className)
    {
        if (isset($this->mapping[$className])) {
            return $this->mapping[$className];
        }

        $metadata   = new ClassMetadata();
        $reflection = new ReflectionClass($className);

        $metadata->className      = $reflection->name;
        $metadata->riakProperties = $this->getRiakPropertiesMapping($reflection);

        return $this->mapping[$className] = $metadata;
    }
98882
public function loadMetadataForClass(
        string $className,
        Mapping\ClassMetadata $metadata,
        Mapping\ClassMetadataBuildingContext $metadataBuildingContext
    ) {
        // IMPORTANT: We're handling $metadata as "parent" metadata here, while building the $className ClassMetadata.
        $reflectionClass = new ReflectionClass($className);

        // Evaluate annotations on class metadata
        $classAnnotations = $this->getClassAnnotations($reflectionClass);
        $classMetadata    = $this->convertClassAnnotationsToClassMetadata(
            $classAnnotations,
            $reflectionClass,
            $metadata
        );

        // Evaluate @Cache annotation
        if (isset($classAnnotations[Annotation\Cache::class])) {
            $cacheAnnot = $classAnnotations[Annotation\Cache::class];
            $cache      = $this->convertCacheAnnotationToCacheMetadata($cacheAnnot, $classMetadata);

            $classMetadata->setCache($cache);
        }

        // Evaluate annotations on properties/fields
        /** @var ReflectionProperty $reflectionProperty */
        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            if ($reflectionProperty->getDeclaringClass()->getClassName() !== $reflectionClass->getName()) {
                continue;
            }

            $propertyAnnotations = $this->getPropertyAnnotations($reflectionProperty);
            $property            = $this->convertReflectionPropertyAnnotationsToProperty(
                $reflectionProperty,
                $propertyAnnotations,
                $classMetadata
            );

            $classMetadata->addDeclaredProperty($property);
        }

        return $classMetadata;
    }
777281
private function hydrateDataObject(ClassMetadata $metadata, array $parentName = array())
    {
        $dataObject = new MetadataDataObjectDoctrine2(
            new MetaDataColumnCollection(),
            new MetaDataRelationCollection()
        );

        $columnDataObject = new MetaDataColumn();

        foreach ($metadata->fieldMappings as $field => $columnMetadata) {
            $column = clone $columnDataObject;
            $column->setName($field)
                   ->setType($columnMetadata['type'])
                   ->setLength(isset($columnMetadata['length']) === true ? $columnMetadata['length'] : null)
                   ->setNullable($columnMetadata['nullable'])
                   ->setPrimaryKey((in_array($field, $metadata->identifier) === true ? true : false));

            $dataObject->appendColumn($column);
        }

        $dataObject = $this->hydrateAssociation($metadata, $dataObject, $parentName);

        $dataObject->setName($metadata->name);

        return $dataObject;
    }
296585
protected function getClassMetadata($className)
    {
        if (! isset($this->metadataCache[$className])) {
            $this->metadataCache[$className] = $this->em->getClassMetadata($className);
        }

        return $this->metadataCache[$className];
    }