diff --git a/core/lib/Drupal/Core/Plugin/Discovery/ModuleDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/ModuleDecorator.php deleted file mode 100644 index 8b7f475..0000000 --- a/core/lib/Drupal/Core/Plugin/Discovery/ModuleDecorator.php +++ /dev/null @@ -1,68 +0,0 @@ -decorated = $decorated; - } - - /** - * Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinition(). - */ - public function getDefinition($plugin_id) { - $definitions = $this->getDefinitions(); - return isset($definitions[$plugin_id]) ? $definitions[$plugin_id] : NULL; - } - - - /** - * Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions(). - * - * Loop through each definition, look for a 'module' key, and check it with - * module_exists(). - */ - public function getDefinitions() { - $definitions = array(); - foreach ($this->decorated->getDefinitions() as $plugin_id => $definition) { - if (isset($definition['module']) && module_exists($definition['module'])) { - $definitions[$plugin_id] = $definition; - } - } - return $definitions; - } - - /** - * Passes through all unknown calls onto the decorated object. - */ - public function __call($method, $args) { - return call_user_func_array(array($this->decorated, $method), $args); - } - -} diff --git a/core/lib/Drupal/Core/Plugin/Type/EntityManager.php b/core/lib/Drupal/Core/Plugin/Type/EntityManager.php index 0a0591e..6481cb8 100644 --- a/core/lib/Drupal/Core/Plugin/Type/EntityManager.php +++ b/core/lib/Drupal/Core/Plugin/Type/EntityManager.php @@ -10,7 +10,6 @@ use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Core\Plugin\Discovery\AlterDecorator; -use Drupal\Core\Plugin\Discovery\ModuleDecorator; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\Core\Cache\CacheBackendInterface; @@ -140,7 +139,7 @@ class EntityManager extends PluginManagerBase { * Constructs a new Entity plugin manager. */ public function __construct() { - $this->discovery = new ModuleDecorator(new AlterDecorator(new AnnotatedClassDiscovery('Core', 'Entity'), 'entity_info')); + $this->discovery = new AlterDecorator(new AnnotatedClassDiscovery('Core', 'Entity'), 'entity_info'); $this->factory = new DefaultFactory($this); // Entity type plugins includes translated strings, so each language is @@ -184,7 +183,9 @@ public function getDefinitions() { return $cache->data; } else { - $definitions = parent::getDefinitions(); + // @todo Remove array_filter() once http://drupal.org/node/1780396 is + // resolved. + $definitions = array_filter(parent::getDefinitions()); cache($this->cacheBin)->set($this->cacheKey, $definitions, $this->cacheExpire, $this->cacheTags); return $definitions; } @@ -196,6 +197,12 @@ public function getDefinitions() { protected function processDefinition(&$definition, $plugin_id) { parent::processDefinition($definition, $plugin_id); + // @todo Remove this check once http://drupal.org/node/1780396 is resolved. + if (!module_exists($definition['module'])) { + $definition = NULL; + return; + } + foreach ($definition['view_modes'] as $view_mode => $view_mode_info) { $definition['view_modes'][$view_mode] += array( 'custom settings' => FALSE,