public function ExampleEntityEventSubscribers::entityPreSave in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 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_dispatcherCode
public function entityPreSave(EntityPresaveEvent $event) : void {
$entity = $event
->getEntity();
$entity->special_field->value = 'PreSave!';
}