You are here

public function ExampleEntityEventSubscribers::entityInsert in Hook Event Dispatcher 8.2

Same name and namespace in other branches
  1. 3.x examples/ExampleEntityEventSubscribers.php \Drupal\hook_event_dispatcher\ExampleEntityEventSubscribers::entityInsert()

Entity insert.

Parameters

\Drupal\core_event_dispatcher\Event\Entity\EntityInsertEvent $event: The event.

File

examples/ExampleEntityEventSubscribers.php, line 63

Class

ExampleEntityEventSubscribers
Class ExampleEntityEventSubscribers.

Namespace

Drupal\hook_event_dispatcher

Code

public function entityInsert(EntityInsertEvent $event) : void {

  // Do some fancy stuff with new entity.
  $entity = $event
    ->getEntity();
  $entity->special_field->value = 'Insert!';
}