[1mdiff --git a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php[m
[1mindex bd89a92..2d6c6d9 100644[m
[1m--- a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php[m
[1m+++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php[m
[36m@@ -21,6 +21,15 @@[m
 class AnnotatedClassDiscovery implements DiscoveryInterface {[m
 [m
   /**[m
[32m+[m[32m   * @var array $custom_location[m
[32m+[m[32m   *[m
[32m+[m[32m   * Use a custom location to scan.[m
[32m+[m[32m   *   key is the namespace.[m
[32m+[m[32m   *   value is the directoy.[m
[32m+[m[32m   */[m
[32m+[m[32m  public $custom_location = array();[m
[32m+[m
[32m+[m[32m  /**[m
    * Constructs an AnnotatedClassDiscovery object.[m
    */[m
   function __construct($owner, $type) {[m
[36m@@ -49,33 +58,42 @@[m [mpublic function getDefinitions() {[m
     AnnotationRegistry::registerAutoloadNamespace('Drupal\Core\Annotation', array(DRUPAL_ROOT . '/core/lib'));[m
     // Get all PSR-0 namespaces.[m
     $namespaces = drupal_classloader()->getNamespaces();[m
[31m-    foreach ($namespaces as $ns => $namespace_dirs) {[m
[31m-[m
[32m+[m[32m    // Rewrite all directories.[m
[32m+[m[32m    foreach ($namespaces as $ns => &$namespace_dirs) {[m
       // OS-Safe directory separators.[m
       $ns = str_replace('\\', DIRECTORY_SEPARATOR, $ns);[m
[32m+[m[32m      // Check for the pre-determined directory structure to find plugins.[m
[32m+[m[32m      $prefix = implode(DIRECTORY_SEPARATOR, array([m
[32m+[m[32m        $ns,[m
[32m+[m[32m        'Plugin',[m
[32m+[m[32m        $this->owner,[m
[32m+[m[32m        $this->type[m
[32m+[m[32m      ));[m
[32m+[m[32m      foreach ($namespace_dirs as &$dir) {[m
[32m+[m[32m        $dir = array([m
[32m+[m[32m          'dir' => $dir .= DIRECTORY_SEPARATOR . $prefix,[m
[32m+[m[32m          'class_base' => str_replace([m
[32m+[m[32m            DIRECTORY_SEPARATOR,[m
[32m+[m[32m            '\\',[m
[32m+[m[32m            $prefix[m
[32m+[m[32m          ),[m
[32m+[m[32m        );[m
[32m+[m[32m      }[m
[32m+[m[32m    }[m
[32m+[m[32m    // Merge in the custom locations.[m
[32m+[m[32m    if (!empty($this->custom_location)) {[m
[32m+[m[32m      $namespaces += $this->custom_location;[m
[32m+[m[32m    }[m
 [m
[31m-      foreach ($namespace_dirs as $dir) {[m
[31m-        // Check for the pre-determined directory structure to find plugins.[m
[31m-        $prefix = implode(DIRECTORY_SEPARATOR, array([m
[31m-          $ns,[m
[31m-          'Plugin',[m
[31m-          $this->owner,[m
[31m-          $this->type[m
[31m-        ));[m
[31m-        $dir .= DIRECTORY_SEPARATOR . $prefix;[m
[31m-[m
[31m-        // If the directory structure exists, look for classes.[m
[32m+[m[32m    foreach ($namespaces as $ns => $namespace_dirs) {[m
[32m+[m[32m      foreach ($namespace_dirs as $dir_info) {[m
[32m+[m[32m        $dir = $dir_info['dir'];[m
         if (file_exists($dir)) {[m
           $directories = new DirectoryIterator($dir);[m
           foreach ($directories as $fileinfo) {[m
             // @todo Once core requires 5.3.6, use $fileinfo->getExtension().[m
             if (pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION) == 'php') {[m
[31m-              $class = str_replace([m
[31m-                DIRECTORY_SEPARATOR,[m
[31m-                '\\',[m
[31m-                $prefix . DIRECTORY_SEPARATOR . $fileinfo->getBasename('.php')[m
[31m-              );[m
[31m-[m
[32m+[m[32m              $class = $dir_info['class_base'] . '\\' . $fileinfo->getBasename('.php');[m
               // The filename is already known, so there is no need to find the[m
               // file. However, StaticReflectionParser needs a finder, so use a[m
               // mock version.[m
