You are here

public function StaticPHPDriver::getAllClassNames in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php \Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver::getAllClassNames()

@todo Same code exists in AnnotationDriver, should we re-use it somehow or not worry about it?

Overrides MappingDriver::getAllClassNames

File

vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php, line 86

Class

StaticPHPDriver
The StaticPHPDriver calls a static loadMetadata() method on your entity classes where you can manually populate the ClassMetadata instance.

Namespace

Doctrine\Common\Persistence\Mapping\Driver

Code

public function getAllClassNames() {
  if ($this->classNames !== null) {
    return $this->classNames;
  }
  if (!$this->paths) {
    throw MappingException::pathRequired();
  }
  $classes = array();
  $includedFiles = array();
  foreach ($this->paths as $path) {
    if (!is_dir($path)) {
      throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
    }
    $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
    foreach ($iterator as $file) {
      if ($file
        ->getBasename('.php') == $file
        ->getBasename()) {
        continue;
      }
      $sourceFile = realpath($file
        ->getPathName());
      require_once $sourceFile;
      $includedFiles[] = $sourceFile;
    }
  }
  $declared = get_declared_classes();
  foreach ($declared as $className) {
    $rc = new \ReflectionClass($className);
    $sourceFile = $rc
      ->getFileName();
    if (in_array($sourceFile, $includedFiles) && !$this
      ->isTransient($className)) {
      $classes[] = $className;
    }
  }
  $this->classNames = $classes;
  return $classes;
}