diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index a75dc44..55a4f48 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -10,6 +10,7 @@ use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Core\Plugin\Discovery\AlterDecorator; +use Drupal\Core\Plugin\Discovery\InfoHackDecorator; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\Core\Cache\CacheBackendInterface; @@ -222,7 +223,7 @@ class EntityManager extends PluginManagerBase { */ public function __construct() { // Allow the plugin definition to be altered by hook_entity_info_alter(). - $this->discovery = new AlterDecorator(new AnnotatedClassDiscovery('Core', 'Entity'), 'entity_info'); + $this->discovery = new AlterDecorator(new InfoHackDecorator(new AnnotatedClassDiscovery('Core', 'Entity'), 'entity_info'), 'entity_info'); $this->factory = new DefaultFactory($this); // Entity type plugins includes translated strings, so each language is diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AlterDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/AlterDecorator.php index d4ce40b..8bcee3f 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/AlterDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/AlterDecorator.php @@ -35,7 +35,7 @@ class AlterDecorator implements DiscoveryInterface { * @param Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated * The object implementing DiscoveryInterface that is being decorated. * @param string $hook - * The name of the alter hook that will be implemented by this discovery instance. + * The name of the alter hook that will be used by this discovery instance. */ public function __construct(DiscoveryInterface $decorated, $hook) { $this->decorated = $decorated; diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AlterDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/InfoHackDecorator.php similarity index 63% copy from core/lib/Drupal/Core/Plugin/Discovery/AlterDecorator.php copy to core/lib/Drupal/Core/Plugin/Discovery/InfoHackDecorator.php index d4ce40b..4857289 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/AlterDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/InfoHackDecorator.php @@ -2,19 +2,22 @@ /** * @file - * Definition of Drupal\Core\Plugin\Discovery\AlterDiscoveryDecorator. -*/ + * Definition of Drupal\Core\Plugin\Discovery\InfoHackDecorator. + * + * @todo D8: Remove this decorator once obsoleted by completed upgrades. + */ namespace Drupal\Core\Plugin\Discovery; use Drupal\Component\Plugin\Discovery\DiscoveryInterface; /** - * Enables altering of discovered plugin definitions. + * Enables injection of info hook discovered plugin definitions into existing + * definitions for use in incrementally converting systems. */ -class AlterDecorator implements DiscoveryInterface { +class InfoHackDecorator implements DiscoveryInterface { /** - * The name of the alter hook that will be implemented by this discovery instance. + * The name of the info hook that will be implemented by this discovery instance. * * @var string */ @@ -28,14 +31,15 @@ class AlterDecorator implements DiscoveryInterface { protected $decorated; /** - * Constructs a Drupal\Core\Plugin\Discovery\AlterDecorator object. + * Constructs a Drupal\Core\Plugin\Discovery\InfoHackDecorator object. * * It uses the DiscoveryInterface object it should decorate. * * @param Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated * The object implementing DiscoveryInterface that is being decorated. * @param string $hook - * The name of the alter hook that will be implemented by this discovery instance. + * The name of the info hook that will be implemented by this discovery + * instance. */ public function __construct(DiscoveryInterface $decorated, $hook) { $this->decorated = $decorated; @@ -50,13 +54,17 @@ public function getDefinition($plugin_id) { return isset($definitions[$plugin_id]) ? $definitions[$plugin_id] : NULL; } - /** * Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions(). */ public function getDefinitions() { $definitions = $this->decorated->getDefinitions(); - drupal_alter($this->hook, $definitions); + // Call through to some info hooks to get unconverted definitions. + foreach (module_implements($this->hook) as $module) { + $function = $module . '_' . $this->hook; + $function($definitions); + } + return $definitions; } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 0187bda..64fde4d 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -249,9 +249,9 @@ function book_admin_paths() { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_info(). */ -function book_entity_info_alter(&$info) { +function book_entity_info(&$info) { // Add the 'Print' view mode for nodes. $info['node']['view_modes']['print'] = array( 'label' => t('Print'), diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 7b6eda4..b3db4b7 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -98,9 +98,9 @@ function comment_help($path, $arg) { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_info(). */ -function comment_entity_info_alter(&$info) { +function comment_entity_info(&$info) { foreach (node_type_get_names() as $type => $name) { $info['comment']['bundles']['comment_node_' . $type] = array( 'label' => t('@node_type comment', array('@node_type' => $name)), diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 50395b1..edcf809 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -192,9 +192,9 @@ function node_cron() { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_info(). */ -function node_entity_info_alter(&$info) { +function node_entity_info(&$info) { // Add a translation handler for fields if the language module is enabled. if (module_exists('language')) { $info['node']['translation']['node'] = TRUE; diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 8da637f..d8ea5b7 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -106,9 +106,9 @@ function taxonomy_permission() { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_info(). */ -function taxonomy_entity_info_alter(&$info) { +function taxonomy_entity_info(&$info) { foreach (taxonomy_vocabulary_get_names() as $machine_name => $vocabulary) { $info['taxonomy_term']['bundles'][$machine_name] = array( 'label' => $vocabulary->name,