You are here

function hook_entity_create in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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

hook_ENTITY_TYPE_create()

Related topics

1 function implements 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().
2 invocations of hook_entity_create()
ConfigEntityStorage::createFromStorageRecord in core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php
Creates a configuration entity from storage values.
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 793
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(),
  ]);
}