You are here

public function ExampleEntityEventSubscribers::entityPreSave in Hook Event Dispatcher 8.2

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

Entity pre save.

Parameters

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

File

examples/ExampleEntityEventSubscribers.php, line 52

Class

ExampleEntityEventSubscribers
Class ExampleEntityEventSubscribers.

Namespace

Drupal\hook_event_dispatcher

Code

public function entityPreSave(EntityPresaveEvent $event) : void {
  $entity = $event
    ->getEntity();
  $entity->special_field->value = 'PreSave!';
}