This commit is contained in:
Yuri Kuznetsov
2023-09-02 19:11:35 +03:00
parent 40e7eeb118
commit 6d32879f21
4 changed files with 36 additions and 0 deletions
@@ -29,6 +29,9 @@
namespace Espo\Core\Record\Hook;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Conflict;
use Espo\Core\Exceptions\Forbidden;
use Espo\ORM\Entity;
use Espo\Core\Record\CreateParams;
@@ -39,6 +42,9 @@ interface CreateHook
{
/**
* @param TEntity $entity
* @throws BadRequest
* @throws Forbidden
* @throws Conflict
*/
public function process(Entity $entity, CreateParams $params): void;
}
@@ -29,6 +29,9 @@
namespace Espo\Core\Record\Hook;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Conflict;
use Espo\Core\Exceptions\Forbidden;
use Espo\ORM\Entity;
use Espo\Core\Record\DeleteParams;
@@ -39,6 +42,9 @@ interface DeleteHook
{
/**
* @param TEntity $entity
* @throws BadRequest
* @throws Forbidden
* @throws Conflict
*/
public function process(Entity $entity, DeleteParams $params): void;
}
@@ -29,6 +29,9 @@
namespace Espo\Core\Record\Hook;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Conflict;
use Espo\Core\Exceptions\Forbidden;
use Espo\ORM\Entity;
use Espo\Core\Record\UpdateParams;
@@ -40,6 +43,9 @@ interface UpdateHook
{
/**
* @param TEntity $entity
* @throws BadRequest
* @throws Forbidden
* @throws Conflict
*/
public function process(Entity $entity, UpdateParams $params): void;
}
@@ -29,6 +29,9 @@
namespace Espo\Core\Record;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Conflict;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Record\Hook\CreateHook;
use Espo\Core\Record\Hook\DeleteHook;
use Espo\Core\Record\Hook\LinkHook;
@@ -44,6 +47,11 @@ class HookManager
public function __construct(private Provider $provider)
{}
/**
* @throws BadRequest
* @throws Forbidden
* @throws Conflict
*/
public function processBeforeCreate(Entity $entity, CreateParams $params): void
{
foreach ($this->getBeforeCreateHookList($entity->getEntityType()) as $hook) {
@@ -58,6 +66,11 @@ class HookManager
}
}
/**
* @throws BadRequest
* @throws Forbidden
* @throws Conflict
*/
public function processBeforeUpdate(Entity $entity, UpdateParams $params): void
{
foreach ($this->getBeforeUpdateHookList($entity->getEntityType()) as $hook) {
@@ -65,6 +78,11 @@ class HookManager
}
}
/**
* @throws BadRequest
* @throws Forbidden
* @throws Conflict
*/
public function processBeforeDelete(Entity $entity, DeleteParams $params): void
{
foreach ($this->getBeforeDeleteHookList($entity->getEntityType()) as $hook) {