I am creating a custom module:
In this module, I have created an `afterSave` hook:
MyHook.php
My question is this:
If I do an update to the Entity in my hook
this will trigger an endless loop.
If I use the SKIP_HOOKS save option
then all Workflows and Hooks will not trigger.
How can I update the Entity in my afterSave hook and skip ONLY my hook and let all other workflows trigger afterSave?
Code:
namespace Espo\Modules\MyModule;
Code:
<root>
|-- custom
|-- Espo
|-- Modules
|-- MyModule
|-- Hooks
|-- Contact
|-- MyHook.php
MyHook.php
Code:
public function afterSave(Entity $entity, SaveOptions $options): void
{
\\ my code here
}
If I do an update to the Entity in my hook
Code:
$entityManager->saveEntity($entity)
If I use the SKIP_HOOKS save option
Code:
$entityManager->saveEntity($entity, [SaveOption::SKIP_HOOKS => true]);
How can I update the Entity in my afterSave hook and skip ONLY my hook and let all other workflows trigger afterSave?

Comment