public function AbstractClassMetadataFactory::getMetadataFor

Gets the class metadata descriptor for a class.

Parameters

string $className The name of the class.:

Return value

\Doctrine\Common\Persistence\Mapping\ClassMetadata

Overrides ClassMetadataFactory::getMetadataFor

1 call to AbstractClassMetadataFactory::getMetadataFor()
AbstractClassMetadataFactory::getAllMetadata in drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php
Forces the factory to load the metadata of all classes known to the underlying mapping driver.

File

drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php, line 177

Class

AbstractClassMetadataFactory
The ClassMetadataFactory is used to create ClassMetadata objects that contain all the metadata mapping informations of a class which describes how a class should be mapped to a relational database.

Namespace

Doctrine\Common\Persistence\Mapping

Code

public function getMetadataFor($className) {
  if (isset($this->loadedMetadata[$className])) {
    return $this->loadedMetadata[$className];
  }
  $realClassName = $className;

  // Check for namespace alias
  if (strpos($className, ':') !== false) {
    list($namespaceAlias, $simpleClassName) = explode(':', $className);
    $realClassName = $this
      ->getFqcnFromAlias($namespaceAlias, $simpleClassName);
  }
  else {
    $realClassName = ClassUtils::getRealClass($realClassName);
  }
  if (isset($this->loadedMetadata[$realClassName])) {

    // We do not have the alias name in the map, include it
    $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
    return $this->loadedMetadata[$realClassName];
  }
  if ($this->cacheDriver) {
    if (($cached = $this->cacheDriver
      ->fetch($realClassName . $this->cacheSalt)) !== false) {
      $this->loadedMetadata[$realClassName] = $cached;
      $this
        ->wakeupReflection($cached, $this
        ->getReflectionService());
    }
    else {
      foreach ($this
        ->loadMetadata($realClassName) as $loadedClassName) {
        $this->cacheDriver
          ->save($loadedClassName . $this->cacheSalt, $this->loadedMetadata[$loadedClassName], null);
      }
    }
  }
  else {
    $this
      ->loadMetadata($realClassName);
  }
  if ($className != $realClassName) {

    // We do not have the alias name in the map, include it
    $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
  }
  return $this->loadedMetadata[$className];
}