src/Eccube/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php line 86

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Doctrine\ORM\Mapping\Driver;
  13. use Doctrine\Persistence\Mapping\MappingException;
  14. class AnnotationDriver extends \Doctrine\ORM\Mapping\Driver\AnnotationDriver
  15. {
  16.     protected $trait_proxies_directory;
  17.     public function setTraitProxiesDirectory($dir)
  18.     {
  19.         $this->trait_proxies_directory $dir;
  20.     }
  21.     /**
  22.      * {@inheritdoc}
  23.      */
  24.     public function getAllClassNames()
  25.     {
  26.         if ($this->classNames !== null) {
  27.             return $this->classNames;
  28.         }
  29.         if ($this->paths === []) {
  30.             throw MappingException::pathRequiredForDriver(static::class);
  31.         }
  32.         $classes = [];
  33.         $includedFiles = [];
  34.         foreach ($this->paths as $path) {
  35.             if (!is_dir($path)) {
  36.                 throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);
  37.             }
  38.             $iterator = new \RegexIterator(
  39.                 new \RecursiveIteratorIterator(
  40.                     new \RecursiveDirectoryIterator($path\FilesystemIterator::SKIP_DOTS),
  41.                     \RecursiveIteratorIterator::LEAVES_ONLY
  42.                 ),
  43.                 '/^.+'.preg_quote($this->fileExtension).'$/i',
  44.                 \RecursiveRegexIterator::GET_MATCH
  45.             );
  46.             foreach ($iterator as $file) {
  47.                 $sourceFile $file[0];
  48.                 if (!preg_match('(^phar:)i'$sourceFile)) {
  49.                     $sourceFile realpath($sourceFile);
  50.                 }
  51.                 foreach ($this->excludePaths as $excludePath) {
  52.                     $exclude str_replace('\\''/'realpath($excludePath));
  53.                     $current str_replace('\\''/'$sourceFile);
  54.                     if (strpos($current$exclude) !== false) {
  55.                         continue 2;
  56.                     }
  57.                 }
  58.                 $projectDir realpath(__DIR__.'/../../../../../../');
  59.                 if ('\\' === DIRECTORY_SEPARATOR) {
  60.                     $path str_replace('\\''/'$path);
  61.                     $this->trait_proxies_directory str_replace('\\''/'$this->trait_proxies_directory);
  62.                     $sourceFile str_replace('\\''/'$sourceFile);
  63.                     $projectDir str_replace('\\''/'$projectDir);
  64.                 }
  65.                 // Replace /path/to/ec-cube to proxies path
  66.                 $proxyFile str_replace($projectDir$this->trait_proxies_directory$path).'/'.basename($sourceFile);
  67.                 if (file_exists($proxyFile)) {
  68.                     require_once $proxyFile;
  69.                     $sourceFile $proxyFile;
  70.                 } else {
  71.                     require_once $sourceFile;
  72.                 }
  73.                 $includedFiles[] = realpath($sourceFile);
  74.             }
  75.         }
  76.         $declared get_declared_classes();
  77.         foreach ($declared as $className) {
  78.             $rc = new \ReflectionClass($className);
  79.             $sourceFile $rc->getFileName();
  80.             if (in_array($sourceFile$includedFiles) && !$this->isTransient($className)) {
  81.                 $classes[] = $className;
  82.             }
  83.         }
  84.         $this->classNames $classes;
  85.         return $classes;
  86.     }
  87. }