You are here

public function SymfonyFileLocator::getAllClassNames in Zircon Profile 8.0

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

Gets all class names that are found with this file locator.

Parameters

string $globalBasename Passed to allow excluding the basename.:

Return value

array

Overrides FileLocator::getAllClassNames

File

vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php, line 165

Class

SymfonyFileLocator
The Symfony File Locator makes a simplifying assumptions compared to the DefaultFileLocator. By assuming paths only contain entities of a certain namespace the mapping files consists of the short classname only.

Namespace

Doctrine\Common\Persistence\Mapping\Driver

Code

public function getAllClassNames($globalBasename = null) {
  $classes = array();
  if ($this->paths) {
    foreach ((array) $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) {
        $fileName = $file
          ->getBasename($this->fileExtension);
        if ($fileName == $file
          ->getBasename() || $fileName == $globalBasename) {
          continue;
        }

        // NOTE: All files found here means classes are not transient!
        if (isset($this->prefixes[$path])) {

          // Calculate namespace suffix for given prefix as a relative path from basepath to file path
          $nsSuffix = strtr(substr(realpath($file
            ->getPath()), strlen(realpath($path))), $this->nsSeparator, '\\');
          $classes[] = $this->prefixes[$path] . $nsSuffix . '\\' . str_replace($this->nsSeparator, '\\', $fileName);
        }
        else {
          $classes[] = str_replace($this->nsSeparator, '\\', $fileName);
        }
      }
    }
  }
  return $classes;
}