Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory::loadMetadata PHP Method

loadMetadata() protected method

Important: The class $name does not necesarily exist at this point here. Scenarios in a code-generation setup might have access to XML/YAML Mapping files without the actual PHP code existing here. That is why the {@see \Doctrine\Common\Persistence\Mapping\ReflectionService} interface should be used for reflection.
protected loadMetadata ( string $name ) : array
$name string The name of the class for which the metadata should get loaded.
return array
    protected function loadMetadata($name)
    {
        if (!$this->initialized) {
            $this->initialize();
        }
        $loaded = [];
        $parentClasses = $this->getParentClasses($name);
        $parentClasses[] = $name;
        // Move down the hierarchy of parent classes, starting from the topmost class
        $parent = null;
        $rootEntityFound = false;
        $visited = [];
        $reflService = $this->getReflectionService();
        foreach ($parentClasses as $className) {
            if (isset($this->loadedMetadata[$className])) {
                $parent = $this->loadedMetadata[$className];
                if ($this->isEntity($parent)) {
                    $rootEntityFound = true;
                    array_unshift($visited, $className);
                }
                continue;
            }
            $class = $this->newClassMetadataInstance($className);
            $this->initializeReflection($class, $reflService);
            $this->doLoadMetadata($class, $parent, $rootEntityFound, $visited);
            $this->loadedMetadata[$className] = $class;
            $parent = $class;
            if ($this->isEntity($class)) {
                $rootEntityFound = true;
                array_unshift($visited, $className);
            }
            $this->wakeupReflection($class, $reflService);
            $loaded[] = $className;
        }
        return $loaded;
    }

Usage Example

 /**
  * {@inheritdoc}
  *
  * @throws MappingException
  */
 public function loadMetadata($className)
 {
     if (class_exists($className)) {
         return parent::loadMetadata($className);
     }
     throw MappingException::classNotFound($className);
 }
All Usage Examples Of Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory::loadMetadata