getBeforeCreateHookList($entity->getEntityType()) as $hook) { if ($hook instanceof SaveHook) { $hook->process($entity); continue; } $hook->process($entity, $params); } } public function processBeforeRead(Entity $entity, ReadParams $params): void { foreach ($this->getBeforeReadHookList($entity->getEntityType()) as $hook) { $hook->process($entity, $params); } } /** * @throws BadRequest * @throws Forbidden * @throws Conflict */ public function processBeforeUpdate(Entity $entity, UpdateParams $params): void { foreach ($this->getBeforeUpdateHookList($entity->getEntityType()) as $hook) { if ($hook instanceof SaveHook) { $hook->process($entity); continue; } $hook->process($entity, $params); } } /** * @throws BadRequest * @throws Forbidden * @throws Conflict */ public function processBeforeDelete(Entity $entity, DeleteParams $params): void { foreach ($this->getBeforeDeleteHookList($entity->getEntityType()) as $hook) { $hook->process($entity, $params); } } public function processBeforeLink(Entity $entity, string $link, Entity $foreignEntity): void { foreach ($this->getBeforeLinkHookList($entity->getEntityType()) as $hook) { $hook->process($entity, $link, $foreignEntity); } } public function processBeforeUnlink(Entity $entity, string $link, Entity $foreignEntity): void { foreach ($this->getBeforeUnlinkHookList($entity->getEntityType()) as $hook) { $hook->process($entity, $link, $foreignEntity); } } /** * @return ReadHook[] */ private function getBeforeReadHookList(string $entityType): array { /** @var ReadHook[] */ return $this->provider->getList($entityType, Type::BEFORE_READ); } /** * @return (CreateHook|SaveHook)[] */ private function getBeforeCreateHookList(string $entityType): array { /** @var CreateHook[] */ return $this->provider->getList($entityType, Type::BEFORE_CREATE); } /** * @return (UpdateHook|SaveHook)[] */ private function getBeforeUpdateHookList(string $entityType): array { /** @var UpdateHook[] */ return $this->provider->getList($entityType, Type::BEFORE_UPDATE); } /** * @return DeleteHook[] */ private function getBeforeDeleteHookList(string $entityType): array { /** @var DeleteHook[] */ return $this->provider->getList($entityType, Type::BEFORE_DELETE); } /** * @return LinkHook[] */ private function getBeforeLinkHookList(string $entityType): array { /** @var LinkHook[] */ return $this->provider->getList($entityType, Type::BEFORE_LINK); } /** * @return UnlinkHook[] */ private function getBeforeUnlinkHookList(string $entityType): array { /** @var UnlinkHook[] */ return $this->provider->getList($entityType, Type::BEFORE_UNLINK); } }