diff --git a/core/includes/entity.inc b/core/includes/entity.inc index c2054c2d9790..56db62d2c0bf 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -10,33 +10,6 @@ use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Language\Language; -/** - * Gets the entity definition for an entity type. - * - * @param string|null $entity_type - * (optional) The entity type (e.g. 'node'). Leave NULL to retrieve - * information for all entity types. - * - * @return array - * An array containing the entity type's definition, as retrieved with - * \Drupal\Core\Entity\EntityManagerInterface. If $entity_type is NULL, an - * associative array of all entity type definitions keyed by entity type is - * returned. - * - * @see \Drupal\Core\Entity\EntityManagerInterface - * @see hook_entity_info_alter() - * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getDefinitions() directly. - */ -function entity_get_info($entity_type = NULL) { - if (empty($entity_type)) { - return \Drupal::entityManager()->getDefinitions(); - } - else { - return \Drupal::entityManager()->getDefinition($entity_type); - } -} - /** * Resets the cached information about entity types. */ @@ -131,7 +104,7 @@ function entity_get_form_modes($entity_type = NULL) { $form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode; } drupal_alter('entity_form_mode_info', $form_modes); - cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_info' => TRUE)); + cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_types' => TRUE)); } } @@ -169,7 +142,7 @@ function entity_get_view_modes($entity_type = NULL) { $view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode; } drupal_alter('entity_view_mode_info', $view_modes); - cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_info' => TRUE)); + cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_types' => TRUE)); } } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 6a2385f9ae7c..d100546c2fda 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -30,7 +30,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Manages entity type plugin definitions. * * Each entity type definition array is set in the entity type's - * annotation and altered by hook_entity_info_alter(). + * annotation and altered by hook_entity_type_alter(). * * The defaults for the plugin definition are provided in * \Drupal\Core\Entity\EntityManagerInterface::defaults. @@ -38,7 +38,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * @see \Drupal\Core\Entity\Annotation\EntityType * @see \Drupal\Core\Entity\EntityInterface * @see \Drupal\Core\Entity\EntityTypeInterface - * @see hook_entity_info_alter() + * @see hook_entity_type_alter() */ class EntityManager extends PluginManagerBase implements EntityManagerInterface { @@ -134,7 +134,7 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface * The string translationManager. */ public function __construct(\Traversable $namespaces, ContainerInterface $container, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManager $language_manager, TranslationInterface $translation_manager) { - // Allow the plugin definition to be altered by hook_entity_info_alter(). + // Allow the plugin definition to be altered by hook_entity_type_alter(). $this->moduleHandler = $module_handler; $this->cache = $cache; @@ -143,9 +143,9 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface $this->translationManager = $translation_manager; $this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); - $this->discovery = new InfoHookDecorator($this->discovery, 'entity_info'); - $this->discovery = new AlterDecorator($this->discovery, 'entity_info'); - $this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . $this->languageManager->getCurrentLanguage()->id, 'cache', Cache::PERMANENT, array('entity_info' => TRUE)); + $this->discovery = new InfoHookDecorator($this->discovery, 'entity_type_build'); + $this->discovery = new AlterDecorator($this->discovery, 'entity_type'); + $this->discovery = new CacheDecorator($this->discovery, 'entity_type:' . $this->languageManager->getCurrentLanguage()->id, 'cache', Cache::PERMANENT, array('entity_types' => TRUE)); $this->container = $container; } @@ -352,7 +352,7 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface } } - $this->cache->set($cid, $this->entityFieldInfo[$entity_type_id], Cache::PERMANENT, array('entity_info' => TRUE, 'entity_field_info' => TRUE)); + $this->cache->set($cid, $this->entityFieldInfo[$entity_type_id], Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE)); } } @@ -414,7 +414,7 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface } } $this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo); - $this->cache->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_info' => TRUE)); + $this->cache->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_types' => TRUE)); } } diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php index cbe2871c43e0..3da5abc67567 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php @@ -12,7 +12,7 @@ namespace Drupal\Core\Entity; * * All entity controller classes specified via the "controllers['storage']" key * returned by \Drupal\Core\Entity\EntityManagerInterface or - * hook_entity_info_alter() have to implement this interface. + * hook_entity_type_alter() have to implement this interface. * * Most simple, SQL-based entity controllers will do better by extending * Drupal\Core\Entity\DatabaseStorageController instead of implementing this diff --git a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php index 4305c6b8853e..857d3e7592b7 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -10,8 +10,8 @@ namespace Drupal\Core\Entity; /** * Provides an interface for an entity type and its metadata. * - * Additional information can be provided by modules: hook_entity_info() can be - * implemented to define new properties, while hook_entity_info_alter() can be + * Additional information can be provided by modules: hook_entity_type_build() can be + * implemented to define new properties, while hook_entity_type_alter() can be * implemented to alter existing data and fill-in defaults. Module-specific * properties should be documented in the hook implementations defining them. */ diff --git a/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php b/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php index 828508bc0ad6..1b8a466176c3 100644 --- a/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php @@ -49,7 +49,7 @@ class UpdateModuleHandler extends ModuleHandler { // This is called during rebuild to find testing themes. case 'system_theme_info': // Those are needed by user_access() to check access on update.php. - case 'entity_info': + case 'entity_type_build': case 'entity_load': case 'user_role_load': return array(); diff --git a/core/modules/action/action.module b/core/modules/action/action.module index cc6821b2e30b..07e7b48fbda2 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -71,11 +71,11 @@ function action_menu_link_defaults() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_type_build(). */ -function action_entity_info(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_info['action'] +function action_entity_type_build(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + $entity_types['action'] ->setFormClass('add', 'Drupal\action\ActionAddFormController') ->setFormClass('edit', 'Drupal\action\ActionEditFormController') ->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm') diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index d4d7297dd7ca..0d16abfe109a 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -136,15 +136,15 @@ function custom_block_load($id) { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function custom_block_entity_info_alter(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ +function custom_block_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ // Add a translation handler for fields if the language module is enabled. if (\Drupal::moduleHandler()->moduleExists('language')) { - $translation = $entity_info['custom_block']->get('translation'); + $translation = $entity_types['custom_block']->get('translation'); $translation['custom_block'] = TRUE; - $entity_info['custom_block']->set('translation', $translation); + $entity_types['custom_block']->set('translation', $translation); } } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 8fe9e41e7ade..138da2ee6dfa 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -112,11 +112,11 @@ function book_permission() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_type_build(). */ -function book_entity_info(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_info['node'] +function book_entity_type_build(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + $entity_types['node'] ->setFormClass('book_outline', 'Drupal\book\Form\BookOutlineForm') ->setLinkTemplate('book-outline-form', 'book.outline') ->setLinkTemplate('book-remove-form', 'book.remove'); diff --git a/core/modules/comment/tests/modules/comment_test/comment_test.module b/core/modules/comment/tests/modules/comment_test/comment_test.module index 10f521b6c84b..7ff9376b1a4b 100644 --- a/core/modules/comment/tests/modules/comment_test/comment_test.module +++ b/core/modules/comment/tests/modules/comment_test/comment_test.module @@ -9,15 +9,15 @@ use Drupal\comment\CommentInterface; /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function comment_test_entity_info_alter(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ +function comment_test_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ if (\Drupal::languageManager()->isMultilingual()) { // Enable language handling for comment fields. - $translation = $entity_info['comment']->get('translation'); + $translation = $entity_types['comment']->get('translation'); $translation['comment_test'] = TRUE; - $entity_info['comment']->set('translation', $translation); + $entity_types['comment']->set('translation', $translation); } } diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index 4fb13e316a2d..0a16756fa378 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -64,18 +64,18 @@ function config_test_config_test_create(ConfigTest $config_test) { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function config_test_entity_info_alter(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ +function config_test_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ // The 'translatable' entity key is not supposed to change over time. In this // case we can safely do it because we set it once and we do not change it for // all the duration of the test session. - $entity_info['config_test']->set('translatable', \Drupal::service('state')->get('config_test.translatable')); + $entity_types['config_test']->set('translatable', \Drupal::service('state')->get('config_test.translatable')); // Create a clone of config_test that does not have a status. - $entity_info['config_test_no_status'] = clone $entity_info['config_test']; - $config_test_no_status = &$entity_info['config_test_no_status']; + $entity_types['config_test_no_status'] = clone $entity_types['config_test']; + $config_test_no_status = &$entity_types['config_test_no_status']; $config_test_no_status->setLinkTemplate('edit-form', 'config_test.entity_config_test_no_status'); $config_test_no_status->setLinkTemplate('delete-form', 'config_test.entity_delete_config_test_no_status'); diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 62f014f2a911..6730dba31c08 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -85,11 +85,11 @@ function config_translation_theme() { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function config_translation_entity_info_alter($entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - foreach ($entity_info as $entity_type_id => $entity_type) { +function config_translation_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + foreach ($entity_types as $entity_type_id => $entity_type) { if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) { if ($entity_type_id == 'block') { $class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListController'; diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module index ac6fb3f7f5cc..5c4f5d496de6 100644 --- a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module +++ b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module @@ -6,12 +6,12 @@ */ /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function config_translation_test_entity_info_alter(&$entity_info) { +function config_translation_test_entity_type_alter(array &$entity_types) { // Remove entity definition for these entity types from config_test module. - unset($entity_info['config_test_no_status']); - unset($entity_info['config_query_test']); + unset($entity_types['config_test_no_status']); + unset($entity_types['config_query_test']); } /** diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index a3246a36b679..bd9454f1f475 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -100,11 +100,11 @@ function contact_menu_link_defaults() { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function contact_entity_info_alter(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_info['user']->setLinkTemplate('contact-form', 'contact.personal_page'); +function contact_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + $entity_types['user']->setLinkTemplate('contact-form', 'contact.personal_page'); } /** diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index aea93499d85d..ed17ef4a9916 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -55,7 +55,7 @@ function content_translation_module_implements_alter(&$implementations, $hook) { switch ($hook) { // Move some of our hook implementations to the end of the list. case 'menu_alter': - case 'entity_info_alter': + case 'entity_type_alter': $group = $implementations['content_translation']; unset($implementations['content_translation']); $implementations['content_translation'] = $group; @@ -74,10 +74,10 @@ function content_translation_language_types_info_alter(array &$language_types) { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). * * The content translation UI relies on the entity info to provide its features. - * See the documentation of hook_entity_info() in the Entity API documentation + * See the documentation of hook_entity_type_build() in the Entity API documentation * for more details on all the entity info keys that may be defined. * * To make Content Translation automatically support an entity type some keys @@ -100,24 +100,24 @@ function content_translation_language_types_info_alter(array &$language_types) { * * @see \Drupal\Core\Entity\Annotation\EntityType */ -function content_translation_entity_info_alter(array &$entity_info) { +function content_translation_entity_type_alter(array &$entity_types) { // Provide defaults for translation info. - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - foreach ($entity_info as $entity_type => &$info) { - if ($info->isTranslatable()) { - if (!$info->hasControllerClass('translation')) { - $info->setControllerClass('translation', 'Drupal\content_translation\ContentTranslationController'); + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + foreach ($entity_types as $entity_type) { + if ($entity_type->isTranslatable()) { + if (!$entity_type->hasControllerClass('translation')) { + $entity_type->setControllerClass('translation', 'Drupal\content_translation\ContentTranslationController'); } - $translation = $info->get('translation'); + $translation = $entity_type->get('translation'); if (!$translation || !isset($translation['content_translation'])) { $translation['content_translation'] = array(); } - if ($info->hasLinkTemplate('canonical')) { + if ($entity_type->hasLinkTemplate('canonical')) { // Provide default route names for the translation paths. - if (!$info->hasLinkTemplate('drupal:content-translation-overview')) { - $info->setLinkTemplate('drupal:content-translation-overview', "content_translation.translation_overview_$entity_type"); + if (!$entity_type->hasLinkTemplate('drupal:content-translation-overview')) { + $entity_type->setLinkTemplate('drupal:content-translation-overview', "content_translation.translation_overview_" . $entity_type->id()); } // @todo Remove this as soon as menu access checks rely on the // controller. See https://drupal.org/node/2155787. @@ -125,7 +125,7 @@ function content_translation_entity_info_alter(array &$entity_info) { 'access_callback' => 'content_translation_translate_access', ); } - $info->set('translation', $translation); + $entity_type->set('translation', $translation); } } } diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 59c6deb6b336..d6130919b091 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -29,12 +29,12 @@ use Drupal\Core\Field\FieldDefinitionInterface; * The Field Attach API uses the concept of bundles: the set of fields for a * given entity is defined on a per-bundle basis. The collection of bundles for * an entity type is added to the entity definition with - * hook_entity_info_alter(). For instance, node_entity_info_alter() exposes + * hook_entity_type_alter(). For instance, node_entity_type_alter() exposes * each node type as its own bundle. This means that the set of fields of a * node is determined by the node type. * * The Field API reads the bundle name for a given entity from a particular - * property of the entity object, and hook_entity_info_alter() defines which + * property of the entity object, and hook_entity_type_alter() defines which * property to use. For instance, \Drupal\node\Entity\Node specifies: * @code * entity_keys = { diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php index e2d57ec3c121..32ffe10adc4d 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php @@ -314,10 +314,10 @@ class FieldInfoTest extends FieldUnitTestBase { // Now rebuild the field info cache, and set a variable which will cause // the cache to be cleared while it's being rebuilt; see - // field_test_entity_info(). Ensure the test field is still in the returned + // field_test_entity_type_build(). Ensure the test field is still in the returned // array. field_info_cache_clear(); - \Drupal::state()->set('field_test.clear_info_cache_in_hook_entity_info', TRUE); + \Drupal::state()->set('field_test.clear_info_cache_in_hook_entity_type_build', TRUE); $fields = field_info_fields(); $this->assertTrue(isset($fields[$field->uuid]), 'The test field is found in the array returned by field_info_fields() even if its cache is cleared while being rebuilt.'); } diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index af135909cbf9..2d6a96bf2a1c 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -7,24 +7,24 @@ use Drupal\Core\Entity\EntityInterface; */ /** - * Implements hook_entity_info(). + * Implements hook_entity_type_build(). */ -function field_test_entity_info() { +function field_test_entity_type_build() { /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ // If requested, clear the field cache while this is being called. See // Drupal\field\Tests\FieldInfoTest::testFieldInfoCache(). - if (\Drupal::state()->get('field_test.clear_info_cache_in_hook_entity_info')) { + if (\Drupal::state()->get('field_test.clear_info_cache_in_hook_entity_type_build')) { field_info_cache_clear(); } } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function field_test_entity_info_alter(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ +function field_test_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ foreach (field_test_entity_info_translatable() as $entity_type => $translatable) { - $entity_info[$entity_type]->set('translatable', $translatable); + $entity_types[$entity_type]->set('translatable', $translatable); } } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 80093da8622c..b43c17902c43 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -130,16 +130,16 @@ function field_ui_element_info() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_type_build(). */ -function field_ui_entity_info(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_info['field_instance_config']->setFormClass('delete', 'Drupal\field_ui\Form\FieldInstanceConfigDeleteForm'); - $entity_info['field_config']->setListClass('Drupal\field_ui\FieldConfigListController'); +function field_ui_entity_type_build(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + $entity_types['field_instance_config']->setFormClass('delete', 'Drupal\field_ui\Form\FieldInstanceConfigDeleteForm'); + $entity_types['field_config']->setListClass('Drupal\field_ui\FieldConfigListController'); - foreach ($entity_info as $info) { - if ($bundle = $info->getBundleOf()) { - $info + foreach ($entity_types as $entity_type) { + if ($bundle = $entity_type->getBundleOf()) { + $entity_type ->setLinkTemplate('field_ui-fields', "field_ui.overview_$bundle") ->setLinkTemplate('field_ui-form-display', "field_ui.form_display_overview_$bundle") ->setLinkTemplate('field_ui-display', "field_ui.display_overview_$bundle"); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 18e41496b1d0..deac47552835 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -203,12 +203,12 @@ function forum_menu_local_tasks(&$data, $route_name) { } /** - * Implements hook_entity_info(). + * Implements hook_entity_type_build(). */ -function forum_entity_info(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ +function forum_entity_type_build(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ // Register forum specific form controllers. - $entity_info['taxonomy_term'] + $entity_types['taxonomy_term'] ->setFormClass('forum', 'Drupal\forum\Form\ForumFormController') ->setFormClass('container', 'Drupal\forum\Form\ContainerFormController') ->setLinkTemplate('forum-delete-form', 'forum.delete') diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 5199bea0aa49..82145b4e8c1d 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -106,11 +106,11 @@ function menu_menu_link_defaults() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_type_build(). */ -function menu_entity_info(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_info['menu'] +function menu_entity_type_build(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + $entity_types['menu'] ->setFormClass('add', 'Drupal\menu\MenuFormController') ->setFormClass('edit', 'Drupal\menu\MenuFormController') ->setFormClass('delete', 'Drupal\menu\Form\MenuDeleteForm') @@ -119,7 +119,7 @@ function menu_entity_info(&$entity_info) { ->setLinkTemplate('delete-form', 'menu.delete_menu') ->setLinkTemplate('edit-form', 'menu.menu_edit'); - $entity_info['menu_link'] + $entity_types['menu_link'] ->setFormClass('delete', 'Drupal\menu\Form\MenuLinkDeleteForm') ->setFormClass('reset', 'Drupal\menu\Form\MenuLinkResetForm') ->setLinkTemplate('delete-form', 'menu.link_delete'); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 84612af0755f..4b7fd53c29cc 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -341,7 +341,7 @@ function node_type_get_names() { return $cache->data; } // Not using node_type_get_types() or entity_load_multiple() here, to allow - // this function being used in hook_entity_info() implementations. + // this function being used in hook_entity_type_build() implementations. // @todo Consider to convert this into a generic config entity helper. $config_names = config_get_storage_names_with_prefix('node.type.'); $names = array(); diff --git a/core/modules/rest/lib/Drupal/rest/LinkManager/TypeLinkManager.php b/core/modules/rest/lib/Drupal/rest/LinkManager/TypeLinkManager.php index 81f51742e77a..488032c650cc 100644 --- a/core/modules/rest/lib/Drupal/rest/LinkManager/TypeLinkManager.php +++ b/core/modules/rest/lib/Drupal/rest/LinkManager/TypeLinkManager.php @@ -99,6 +99,6 @@ class TypeLinkManager implements TypeLinkManagerInterface { } // These URIs only change when entity info changes, so cache it permanently // and only clear it when entity_info is cleared. - $this->cache->set('rest:links:types', $data, Cache::PERMANENT, array('entity_info' => TRUE)); + $this->cache->set('rest:links:types', $data, Cache::PERMANENT, array('entity_types' => TRUE)); } } diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 84bfad874719..cdd594654c34 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -99,18 +99,18 @@ function hook_ENTITY_TYPE_create_access(\Drupal\Core\Session\AccountInterface $a * Modules may implement this hook to add information to defined entity types, * as defined in \Drupal\Core\Entity\EntityTypeInterface. * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info + * @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types * An associative array of all entity type definitions, keyed by the entity * type name. Passed by reference. * * @see \Drupal\Core\Entity\Entity * @see \Drupal\Core\Entity\EntityTypeInterface */ -function hook_entity_info(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ +function hook_entity_type_build(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ // Add a form controller for a custom node form without overriding the default - // node form. To override the default node form, use hook_entity_info_alter(). - $entity_info['node']->setFormClass('mymodule_foo', 'Drupal\mymodule\NodeFooFormController'); + // node form. To override the default node form, use hook_entity_type_alter(). + $entity_types['node']->setFormClass('mymodule_foo', 'Drupal\mymodule\NodeFooFormController'); } /** @@ -122,20 +122,20 @@ function hook_entity_info(&$entity_info) { * provided by modules can be altered here. * * Do not use this hook to add information to entity types, unless you are just - * filling-in default values. Use hook_entity_info() instead. + * filling-in default values. Use hook_entity_type_build() instead. * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info + * @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types * An associative array of all entity type definitions, keyed by the entity * type name. Passed by reference. * * @see \Drupal\Core\Entity\Entity * @see \Drupal\Core\Entity\EntityTypeInterface */ -function hook_entity_info_alter(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ +function hook_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ // Set the controller class for nodes to an alternate implementation of the // Drupal\Core\Entity\EntityStorageControllerInterface interface. - $entity_info['node']->setStorageClass('Drupal\mymodule\MyCustomNodeStorageController'); + $entity_types['node']->setStorageClass('Drupal\mymodule\MyCustomNodeStorageController'); } /** diff --git a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module index 61dc1961ce7b..7af346702bc2 100644 --- a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module +++ b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module @@ -6,9 +6,9 @@ */ /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function entity_cache_test_dependency_entity_info_alter(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_info['entity_cache_test']->set('label', \Drupal::state()->get('entity_cache_test.label') ?: 'Entity Cache Test'); +function entity_cache_test_dependency_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + $entity_types['entity_cache_test']->set('label', \Drupal::state()->get('entity_cache_test.label') ?: 'Entity Cache Test'); } diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index e8416a2333d1..7264cf80c77b 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -58,16 +58,16 @@ function entity_test_entity_types($filter = NULL) { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_type_alter(). */ -function entity_test_entity_info_alter(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ +function entity_test_entity_type_alter(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ foreach (entity_test_entity_types() as $entity_type) { // Optionally specify a translation handler for testing translations. if (\Drupal::state()->get('entity_test.translation')) { - $translation = $entity_info[$entity_type]->get('translation'); + $translation = $entity_types[$entity_type]->get('translation'); $translation[$entity_type] = TRUE; - $entity_info[$entity_type]->set('translation', $translation); + $entity_types[$entity_type]->set('translation', $translation); } } } diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 6e931a4bb59c..9b115380f313 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -86,11 +86,11 @@ function views_ui_menu_link_defaults() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_type_build(). */ -function views_ui_entity_info(&$entity_info) { - /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_info['view'] +function views_ui_entity_type_build(array &$entity_types) { + /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ + $entity_types['view'] ->setFormClass('edit', 'Drupal\views_ui\ViewEditFormController') ->setFormClass('add', 'Drupal\views_ui\ViewAddFormController') ->setFormClass('preview', 'Drupal\views_ui\ViewPreviewFormController') diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index 96d59702c42c..60622f0d40a0 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -106,7 +106,7 @@ class EntityManagerTest extends UnitTestCase { $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); $this->moduleHandler->expects($this->any()) ->method('getImplementations') - ->with('entity_info') + ->with('entity_type_build') ->will($this->returnValue(array())); $this->cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');