According to the official EspoCRM documentation, the 7 available global hooks are:
Here is the content of ReadHook.php:
I tried to create a global hook implementing this ReadHook interface. The beforeSave and afterSave methods are working perfectly, but the process() method from ReadHook is not being triggered.
Here’s the complete code I’m using:
Is it possible to register a global hook that listens to the ReadHook event?
Any help would be appreciated!
- beforeSave
- afterSave
- beforeRemove
- afterRemove
- afterRelate
- afterUnrelate
- afterMassRelate
Code:
use Espo\Core\Record\Hook\ReadHook;
Code:
namespace Espo\Core\Record\Hook;
use Espo\ORM\Entity;
use Espo\Core\Record\ReadParams;
/**
* @template TEntity of Entity
*/
interface ReadHook
{
public function process(Entity $entity, ReadParams $params): void;
}
Here’s the complete code I’m using:
Code:
<?php
namespace Espo\Modules\ArcCustomPlugin\Hooks\Common;
use Espo\Core\Hook\Hook\BeforeSave;
use Espo\Core\Hook\Hook\AfterSave;
use Espo\Core\Record\Hook\ReadHook;
use Espo\ORM\Entity;
use Espo\ORM\Repository\Option\SaveOptions;
use Espo\Core\Record\ReadParams;
use Espo\Core\Utils\Log;
class GlobalHook implements BeforeSave, AfterSave, ReadHook
{
public static int $order = 5;
public function __construct(private Log $log)
{
}
public function beforeSave(Entity $entity, SaveOptions $options): void
{
$this->log->debug('GlobalHook - beforeSave');
}
public function afterSave(Entity $entity, SaveOptions $options): void
{
$this->log->debug('GlobalHook - afterSave');
}
public function process(Entity $entity, ReadParams $params): void
{
$entityName = $entity->getEntityType();
$this->log->debug('GlobalHook - process (read hook) - entityName: ' . $entityName);
}
}
Any help would be appreciated!

Comment