Use a pre-save hook for updating the talk date

This commit is contained in:
Oliver Davies 2020-05-26 12:00:35 +01:00
parent 2632f09b7f
commit f5767f7739

View file

@ -18,12 +18,11 @@ final class UpdateTalkCreatedDateOnSave implements EventSubscriberInterface {
public static function getSubscribedEvents() { public static function getSubscribedEvents() {
return [ return [
HookEventDispatcherInterface::ENTITY_INSERT => 'entityInsertOrUpdate', HookEventDispatcherInterface::ENTITY_PRE_SAVE => 'onEntityPreSave',
HookEventDispatcherInterface::ENTITY_UPDATE => 'entityInsertOrUpdate',
]; ];
} }
public function entityInsertOrUpdate(BaseEntityEvent $event): void { public function onEntityPreSave(BaseEntityEvent $event): void {
if ($event->getEntity()->getEntityTypeId() != 'node') { if ($event->getEntity()->getEntityTypeId() != 'node') {
return; return;
} }