From 6a9e3fb02ddf3ebaa4f02cb7cbffc1d778f3afc4 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org> Date: Fri, 24 Jan 2014 12:41:08 +0000 Subject: [PATCH] Issue #2170435 by Xano, EclipseGc: PluginManagerBase::processDefinition() fails when plugin definitions are not arrays. --- .../Component/Plugin/PluginManagerBase.php | 21 ----------------- .../Core/Plugin/DefaultPluginManager.php | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php index 34a5592fa5fa..1fe516009c4f 100644 --- a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php +++ b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php @@ -7,7 +7,6 @@ namespace Drupal\Component\Plugin; -use Drupal\Component\Utility\NestedArray; use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface; /** @@ -36,15 +35,6 @@ abstract class PluginManagerBase implements PluginManagerInterface, CachedDiscov */ protected $mapper; - /** - * A set of defaults to be referenced by $this->processDefinition() if - * additional processing of plugins is necessary or helpful for development - * purposes. - * - * @var array - */ - protected $defaults = array(); - /** * {@inheritdoc} */ @@ -82,15 +72,4 @@ public function getInstance(array $options) { return $this->mapper->getInstance($options); } - /** - * Performs extra processing on plugin definitions. - * - * By default we add defaults for the type to the definition. If a type has - * additional processing logic they can do that by replacing or extending the - * method. - */ - public function processDefinition(&$definition, $plugin_id) { - $definition = NestedArray::mergeDeep($this->defaults, $definition); - } - } diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index 32647355bb88..da6fb437c63c 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -89,6 +89,15 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt */ protected $languageManager; + /** + * A set of defaults to be referenced by $this->processDefinition() if + * additional processing of plugins is necessary or helpful for development + * purposes. + * + * @var array + */ + protected $defaults = array(); + /** * Creates the discovery object. * @@ -230,6 +239,20 @@ protected function setCachedDefinitions($definitions) { $this->definitions = $definitions; } + + /** + * Performs extra processing on plugin definitions. + * + * By default we add defaults for the type to the definition. If a type has + * additional processing logic they can do that by replacing or extending the + * method. + */ + public function processDefinition(&$definition, $plugin_id) { + if (!empty($this->defaults) && is_array($this->defaults)) { + $definition = NestedArray::mergeDeep($this->defaults, $definition); + } + } + /** * Finds plugin definitions. * -- GitLab