function hook_entity_create
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_create()
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_create()
- 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_create()
Acts when creating a new entity.
This hook runs after a new entity object has just been instantiated.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
See also
Related topics
2 functions implement hook_entity_create()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- entity_crud_hook_test_entity_create in core/
modules/ system/ tests/ modules/ entity_crud_hook_test/ entity_crud_hook_test.module - Implements hook_entity_create().
- jsonapi_entity_create in core/
modules/ jsonapi/ jsonapi.module - Implements hook_entity_create().
3 invocations of hook_entity_create()
- ConfigEntityStorage::_doCreateFromStorageRecord in core/
lib/ Drupal/ Core/ Config/ Entity/ ConfigEntityStorage.php - Helps create a configuration entity from storage values.
- ContentEntityStorageBase::create in core/
lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php - Constructs a new entity object, without permanently saving it.
- EntityStorageBase::create in core/
lib/ Drupal/ Core/ Entity/ EntityStorageBase.php - Constructs a new entity object, without permanently saving it.
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 958
Code
function hook_entity_create(\Drupal\Core\Entity\EntityInterface $entity) {
\Drupal::logger('example')->info('Entity created: @label', [
'@label' => $entity->label(),
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.