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

Acts when creating a new entity of a specific type.

This hook runs after a new entity object has just been instantiated.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity object.

See also

hook_entity_create()

Related topics

28 functions implement hook_ENTITY_TYPE_create()

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

comment_field_config_create in core/modules/comment/comment.module
Implements hook_ENTITY_TYPE_create() for 'field_config'.
config_install_dependency_test_config_test_create in core/modules/config/tests/config_install_dependency_test/config_install_dependency_test.module
Implements hook_ENTITY_TYPE_create().
config_test_config_test_create in core/modules/config/tests/config_test/config_test.hooks.inc
Implements hook_ENTITY_TYPE_create() for 'config_test'.
entity_crud_hook_test_block_create in core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_ENTITY_TYPE_create() for block entities.
entity_crud_hook_test_comment_create in core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_ENTITY_TYPE_create() for comment entities.

... See full list

File

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

Code

function hook_ENTITY_TYPE_create(\Drupal\Core\Entity\EntityInterface $entity) {
  \Drupal::logger('example')
    ->info('ENTITY_TYPE created: @label', [
    '@label' => $entity
      ->label(),
  ]);
}