You are here

public function SymfonyFileLocator::fileExists 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::fileExists()

Checks if a file can be found for this class name.

Parameters

string $className:

Return value

bool

Overrides FileLocator::fileExists

File

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

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 fileExists($className) {
  $defaultFileName = str_replace('\\', $this->nsSeparator, $className) . $this->fileExtension;
  foreach ($this->paths as $path) {
    if (!isset($this->prefixes[$path])) {

      // global namespace class
      if (is_file($path . DIRECTORY_SEPARATOR . $defaultFileName)) {
        return true;
      }
      continue;
    }
    $prefix = $this->prefixes[$path];
    if (0 !== strpos($className, $prefix . '\\')) {
      continue;
    }
    $filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', $this->nsSeparator) . $this->fileExtension;
    return is_file($filename);
  }
  return false;
}