I have entity MyEntity provided in module MyModuleOne. In this module I wrote hook for this entity:
I have another module MyModuleTwo. In this module I wrote another hook for this entity:
MyModuleOne has order 50, MyModuleTwo is 100.
When I edit MyEntity in UI I see that hooks are executing:
1) beforeSave from MyModuleTwo
2) afterSave from MyModuleOne
... thats it
afterSave from MyModuleTwo is not executed.
When I changed filename and classname in MyModuleTwo - every hooks are execute as expected.
The reason is - in HookManager checks the class name instead of checking namespace https://github.com/espocrm/espocrm/b...nager.php#L144
This does not guarantee that all hooks will be executed. It would be better to check for a unique namespaces with class names.
PHP Code:
namespace Espo\Modules\MyModuleOne\Hooks\MyEntity;
use Espo\Orm\Entity;
class MyEntityHook extends \Espo\Core\Hooks\Base
{
public function afterSave(Entity $entity, array $options = [])
{
...
}
}
I have another module MyModuleTwo. In this module I wrote another hook for this entity:
PHP Code:
namespace Espo\Modules\MyModuleTwo\Hooks\MyEntity;
use Espo\Orm\Entity;
class MyEntityHook extends \Espo\Core\Hooks\Base
{
public function beforeSave(Entity $entity, array $options = [])
{
...
}
public function afterSave(Entity $entity, array $options = [])
{
...
}
}
MyModuleOne has order 50, MyModuleTwo is 100.
When I edit MyEntity in UI I see that hooks are executing:
1) beforeSave from MyModuleTwo
2) afterSave from MyModuleOne
... thats it
afterSave from MyModuleTwo is not executed.
When I changed filename and classname in MyModuleTwo - every hooks are execute as expected.
The reason is - in HookManager checks the class name instead of checking namespace https://github.com/espocrm/espocrm/b...nager.php#L144
This does not guarantee that all hooks will be executed. It would be better to check for a unique namespaces with class names.
Comment