W3cubDocs

/Drupal 8

function hook_entity_type_build

hook_entity_type_build(array &$entity_types)

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

Hooks
Define functions that alter the behavior of Drupal core.

File

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

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');
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api.php/function/hook_entity_type_build/8.1.x