Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_type_build()
  2. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_type_build()

Add to entity type definitions.

Modules may implement this hook to add information to defined entity types, as defined in \Drupal\Core\Entity\EntityTypeInterface.

To alter existing information or to add information dynamically, use hook_entity_type_alter().

Parameters

\Drupal\Core\Entity\EntityTypeInterface[] $entity_types: An associative array of all entity type definitions, keyed by the entity type name. Passed by reference.

See also

\Drupal\Core\Entity\Entity

\Drupal\Core\Entity\EntityTypeInterface

hook_entity_type_alter()

Related topics

11 functions implement hook_entity_type_build()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

action_entity_type_build in core/modules/action/action.module
Implements hook_entity_type_build().
book_entity_type_build in core/modules/book/book.module
Implements hook_entity_type_build().
comment_display_configurable_test_entity_type_build in core/modules/comment/tests/modules/comment_display_configurable_test/comment_display_configurable_test.module
Implements hook_entity_type_build().
entity_test_constraints_entity_type_build in core/modules/system/tests/modules/entity_test_constraints/entity_test_constraints.module
Implements hook_entity_type_build().
field_ui_entity_type_build in core/modules/field_ui/field_ui.module
Implements hook_entity_type_build().

... See full list

File

core/lib/Drupal/Core/Entity/entity.api.php, line 816
Hooks and documentation related to entities.

Code

function hook_entity_type_build(array &$entity_types) {

  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */

  // Add a form 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('my_module_foo', 'Drupal\\my_module\\NodeFooForm');
}