function hook_entity_type_build

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_type_build()
  2. 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_type_build()
  3. 11.x 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().

TypeInterface

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

hook_entity_type_alter()

Related topics

13 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().
aggregator_display_configurable_test_entity_type_build in core/modules/aggregator/tests/modules/aggregator_display_configurable_test/aggregator_display_configurable_test.module
Implements hook_entity_type_build().
book_entity_type_build in core/modules/book/book.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

1 invocation of hook_entity_type_build()
EntityTypeManager::findDefinitions in core/lib/Drupal/Core/Entity/EntityTypeManager.php
Finds plugin definitions.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 787

Code

function hook_entity_type_build(array &$entity_types) {
    
    /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
    // 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('mymodule_foo', 'Drupal\\mymodule\\NodeFooForm');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.