From 305b2f38da238705a10e543994808ce29dbdbbc0 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Fri, 19 Sep 2014 10:49:07 +0100
Subject: [PATCH] Issue #2309889 by tim.plunkett, dawehner: Fixed DrupalKernel
 requires a Drupal\Core\*\Plugin directory for annotated classes to be
 discovered.

---
 core/lib/Drupal/Core/Datetime/Plugin/README.txt |  4 ----
 core/lib/Drupal/Core/DrupalKernel.php           | 15 ++++++++++++---
 core/lib/Drupal/Core/Render/Plugin/README.txt   |  4 ----
 3 files changed, 12 insertions(+), 11 deletions(-)
 delete mode 100644 core/lib/Drupal/Core/Datetime/Plugin/README.txt
 delete mode 100644 core/lib/Drupal/Core/Render/Plugin/README.txt

diff --git a/core/lib/Drupal/Core/Datetime/Plugin/README.txt b/core/lib/Drupal/Core/Datetime/Plugin/README.txt
deleted file mode 100644
index f761e0198cef..000000000000
--- a/core/lib/Drupal/Core/Datetime/Plugin/README.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-@todo This must be here because DrupalKernel will only allow namespaces to
-  provide plugins if there is a Plugin subdirectory, and git does not allow
-  empty subdirectories. This file should be removed once
-  https://www.drupal.org/node/2309889 is fixed.
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index b75b470f0659..6f7b011a4d2f 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -1010,13 +1010,22 @@ protected function compileContainer() {
 
     // Get a list of namespaces and put it onto the container.
     $namespaces = $this->getModuleNamespacesPsr4($this->getModuleFileNames());
-    // Add all components in \Drupal\Core and \Drupal\Component that have a
-    // Plugin directory.
+    // Add all components in \Drupal\Core and \Drupal\Component that have one of
+    // the following directories:
+    // - Element
+    // - Entity
+    // - Plugin
     foreach (array('Core', 'Component') as $parent_directory) {
       $path = DRUPAL_ROOT . '/core/lib/Drupal/' . $parent_directory;
       $parent_namespace = 'Drupal\\' . $parent_directory;
       foreach (new \DirectoryIterator($path) as $component) {
-        if (!$component->isDot() && $component->isDir() && is_dir($component->getPathname() . '/Plugin')) {
+        /** @var $component \DirectoryIterator */
+        $pathname = $component->getPathname();
+        if (!$component->isDot() && $component->isDir() && (
+          is_dir($pathname . '/Plugin') ||
+          is_dir($pathname . '/Entity') ||
+          is_dir($pathname . '/Element')
+        )) {
           $namespaces[$parent_namespace . '\\' . $component->getFilename()] = $path . '/' . $component->getFilename();
         }
       }
diff --git a/core/lib/Drupal/Core/Render/Plugin/README.txt b/core/lib/Drupal/Core/Render/Plugin/README.txt
deleted file mode 100644
index f761e0198cef..000000000000
--- a/core/lib/Drupal/Core/Render/Plugin/README.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-@todo This must be here because DrupalKernel will only allow namespaces to
-  provide plugins if there is a Plugin subdirectory, and git does not allow
-  empty subdirectories. This file should be removed once
-  https://www.drupal.org/node/2309889 is fixed.
-- 
GitLab