function hook_entity_create in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_create()
- 9 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().
5 invocations of hook_entity_create()
- ConfigEntityStorage::_doCreateFromStorageRecord in core/
lib/ Drupal/ Core/ Config/ Entity/ ConfigEntityStorage.php - Helps create a configuration entity from storage values.
- ConfigEntityStorageTest::testCreate in core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityStorageTest.php - @covers ::create @covers ::doCreate
- ConfigEntityStorageTest::testCreateWithPredefinedUuid in core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityStorageTest.php - @covers ::create @covers ::doCreate
- 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 931 - Hooks and documentation related to entities.
Code
function hook_entity_create(\Drupal\Core\Entity\EntityInterface $entity) {
\Drupal::logger('example')
->info('Entity created: @label', [
'@label' => $entity
->label(),
]);
}