From abfd5335187c4f40d5e2fa8f51cdd27a4d9835a1 Mon Sep 17 00:00:00 2001
From: Carlos Ospina <camoatech@2448054.no-reply.drupal.org>
Date: Wed, 29 Apr 2015 14:38:00 -0500
Subject: [PATCH] Changes to defaultpluginmanager

---
 .../Drupal/Core/Plugin/DefaultPluginManager.php    | 12 ++++++++++-
 core/modules/breakpoint/src/BreakpointManager.php  | 24 ++--------------------
 2 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
index 297f971..e4e05bd 100644
--- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
+++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
@@ -271,7 +271,7 @@ protected function findDefinitions() {
       if (is_object($plugin_definition) && !($plugin_definition = (array) $plugin_definition)) {
         continue;
       }
-      if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && !$this->moduleHandler->moduleExists($plugin_definition['provider'])) {
+      if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && !$this->providerExists($plugin_definition['provider'])) {
         unset($definitions[$plugin_id]);
       }
     }
@@ -290,4 +290,14 @@ protected function alterDefinitions(&$definitions) {
     }
   }
 
+  /**
+   * Determines if the provider of a definition exists.
+   *
+   * @return boolean
+   *   TRUE if provider exists, FALSE otherwise.
+   */
+  protected function providerExists($provider) {
+    return $this->moduleHandler->moduleExists($provider);
+  }
+
 }
diff --git a/core/modules/breakpoint/src/BreakpointManager.php b/core/modules/breakpoint/src/BreakpointManager.php
index 3187912..26a99e1 100644
--- a/core/modules/breakpoint/src/BreakpointManager.php
+++ b/core/modules/breakpoint/src/BreakpointManager.php
@@ -136,28 +136,8 @@ public function processDefinition(&$definition, $plugin_id) {
   /**
    * {@inheritdoc}
    */
-  protected function findDefinitions() {
-    $definitions = $this->discovery->getDefinitions();
-    foreach ($definitions as $plugin_id => &$definition) {
-      $this->processDefinition($definition, $plugin_id);
-    }
-    if ($this->alterHook) {
-      $this->moduleHandler->alter($this->alterHook, $definitions);
-    }
-    // If this plugin was provided by a module that does not exist, remove the
-    // plugin definition.
-    foreach ($definitions as $plugin_id => $plugin_definition) {
-      // If the plugin definition is an object, attempt to convert it to an
-      // array, if that is not possible, skip further processing.
-      if (is_object($plugin_definition) && !($plugin_definition = (array) $plugin_definition)) {
-        continue;
-      }
-      // Allow themes to provide breakpoints.
-      if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && !$this->moduleHandler->moduleExists($plugin_definition['provider']) && !$this->themeHandler->themeExists($plugin_definition['provider'])) {
-        unset($definitions[$plugin_id]);
-      }
-    }
-    return $definitions;
+  protected function providerExists($provider) {
+    return $this->moduleHandler->moduleExists($provider) || $this->themeHandler->themeExists($provider);
   }
 
   /**
-- 
2.3.2 (Apple Git-55)

