By berdir on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
entity_info hooks have been renamed following the introduction of EntityType as a domain object.
hook_entity_infohas been renamed tohook_entity_type_buildhook_entity_info_alterhas been renamed tohook_entity_type_alter
7.x
function mymodule_entity_info_alter(&$entity_info) {
$entity_info['node']['label callback'] = 'my_module_label_callback';
}
8.x
Use hook_entity_type_build() to add definitions to entity types. Use hook_entity_type_alter() to change entity definitions or to set default values.
function mymodule_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_type_alter().
$entity_types['node']->setFormClass('mymodule_foo', 'Drupal\mymodule\NodeFooFormController');
}
function mymodule_entity_type_alter(array &$entity_types) {
/* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['node']->setLabelCallback('my_module_label_callback');
}
Impacts:
Module developers