diff -u b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php --- b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -12,7 +12,6 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Reflection\StaticReflectionParser; -use Doctrine\Common\Reflection\Psr0FindFile; use Drupal\Core\Annotation\Plugin; /** @@ -55,7 +54,9 @@ foreach ($directories as $fileinfo) { if ($fileinfo->getExtension() == 'php') { $className = str_replace(DIRECTORY_SEPARATOR, '\\', "$prefix/". $fileinfo->getBasename('.php')); - $staticReflectionParser = new StaticReflectionParser($className, new Psr0FindFile($namespaces)); + $finder = new Psr0HintedFindFile($namespaces); + $finder->hint($className, $fileInfo->getPathName()); + $staticReflectionParser = new StaticReflectionParser($className, $finder); if ($annotation = $reader->getClassAnnotation($staticReflectionParser->getReflectionClass(), 'Drupal\Core\Annotation\Plugin')) { $definition = $annotation->get(); $definition['class'] = $reflectionClass->name; only in patch2: unchanged: --- /dev/null +++ b/core/lib/Drupal/Core/Plugin/Discovery/Psr0HintedFindFile.php @@ -0,0 +1,34 @@ + filename hints. + * + * @var array + */ + protected $hints = array(); + + /** + * Tell the finder where to find a specific class. + */ + function hint($class, $filename) { + $this->hints[$class] = $filename; + return $this; + } + + /** + * Overrides Doctrine\Common\Reflection\Psr0FindFile::findFile(). + */ + function findFile($class) { + return isset($this->hints[$class]) ? $this->hints[$class] : parent::findFile($class); + } +}