snapshot of https://github.com/espocrm/espocrm.git (master, 2026-09-18; blobs > 131072B omitted)
Some checks failed
Test / Test on PHP 8.3 (push) Failing after 5s
Test / Test on PHP 8.4 (push) Failing after 4s
Test / Test on PHP 8.5 (push) Failing after 3s
TypeScript static analysis / TypeScript check (push) Failing after 14s
Test Integration on MySQL / Test on PHP 8.3 (push) Failing after 2s
Test Integration on MySQL / Test on PHP 8.5 (push) Failing after 0s
Test Integration on PostgreSQL / Test on PHP 8.4 fix (push) Failing after 1s
Test Integration on PostgreSQL / Test on PHP 8.4 master (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-18 04:19:15 +05:00
commit 7cc7e6b4f3
10077 changed files with 900756 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook;
use Espo\Core\Container;
use Espo\Core\HookManager;
/**
* @internal
*
* Serves as a proxy for `HookManager`.
*/
class Control
{
public function __construct(
private Container $container,
) {}
public function enable(): void
{
$this->getHookManager()->enable();
}
public function disable(): void
{
$this->getHookManager()->disable();
}
private function getHookManager(): HookManager
{
return $this->container->getByClass(HookManager::class);
}
}

View File

@@ -0,0 +1,229 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook;
use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\Utils\Config\SystemConfig;
use Espo\Core\Utils\DataCache;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\Utils\Metadata;
use Espo\Core\Utils\Module\PathProvider;
use Espo\Core\Utils\Util;
use LogicException;
/**
* @internal
* @since 10.1.0
*
* To be re-used between requests.
*/
class DataProvider
{
private const int DEFAULT_ORDER = 9;
/** @var ?array<string, array<string, mixed>> */
private $data = null;
private string $cacheKey = 'hooks';
/** @var string[] */
private $ignoredMethodList = [
'__construct',
'getDependencyList',
'inject',
];
public function __construct(
private SystemConfig $systemConfig,
private FileManager $fileManager,
private PathProvider $pathProvider,
#[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private Metadata $metadata,
) {}
/**
* @return array<string, array<string, mixed>>
*/
public function get(): array
{
if (!$this->data) {
$this->load();
}
return $this->data ?? throw new LogicException();
}
private function load(): void
{
if ($this->systemConfig->useCache() && $this->dataCache->has($this->cacheKey)) {
/** @var ?array<string, array<string, mixed>> $cachedData */
$cachedData = $this->dataCache->get($this->cacheKey);
if ($cachedData !== null) {
$this->data = $cachedData;
return;
}
}
$data = $this->readHookData($this->pathProvider->getCustom() . 'Hooks');
foreach ($this->metadata->getModuleList() as $moduleName) {
$modulePath = $this->pathProvider->getModule($moduleName) . 'Hooks';
$data = $this->readHookData($modulePath, $data);
}
$data = $this->readHookData($this->pathProvider->getCore() . 'Hooks', $data);
$this->data = $this->sortHooks($data);
if ($this->systemConfig->useCache()) {
$this->dataCache->store($this->cacheKey, $this->data);
}
}
/**
* @param string $hookDir
* @param array<string, array<string, mixed>> $hookData
* @return array<string, array<string, mixed>>
*/
private function readHookData(string $hookDir, array $hookData = []): array
{
if (!$this->fileManager->exists($hookDir)) {
return $hookData;
}
/** @var array<string, string[]> $fileList */
$fileList = $this->fileManager->getFileList($hookDir, 1, '\.php$', true);
foreach ($fileList as $scopeName => $hookFiles) {
$hookScopeDirPath = Util::concatPath($hookDir, $scopeName);
$normalizedScopeName = Util::normalizeScopeName($scopeName);
foreach ($hookFiles as $hookFile) {
$hookFilePath = Util::concatPath($hookScopeDirPath, $hookFile);
$className = Util::getClassName($hookFilePath);
$classMethods = get_class_methods($className);
$hookMethods = array_diff($classMethods, $this->ignoredMethodList);
/** @var string[] $hookMethods */
$hookMethods = array_filter($hookMethods, function ($item) {
if (str_starts_with($item, 'set')) {
return false;
}
return true;
});
foreach ($hookMethods as $hookType) {
$entityHookData = $hookData[$normalizedScopeName][$hookType] ?? [];
if ($this->hookExists($className, $entityHookData)) {
continue;
}
if ($this->hookClassIsSuppressed($className)) {
continue;
}
$hookData[$normalizedScopeName][$hookType][] = [
'className' => $className,
'order' => $className::$order ?? self::DEFAULT_ORDER,
];
}
}
}
return $hookData;
}
/**
* Check if hook exists in the list.
*
* @param class-string $className
* @param array<string, mixed> $hookData
*/
private function hookExists(string $className, array $hookData): bool
{
$class = preg_replace('/^.*\\\(.*)$/', '$1', $className);
foreach ($hookData as $item) {
if (preg_match('/\\\\'.$class.'$/', $item['className'])) {
return true;
}
}
return false;
}
/**
* Sort hooks by the order parameter.
*
* @param array<string, array<string, mixed>> $hooks
* @return array<string, array<string, mixed>>
*/
private function sortHooks(array $hooks): array
{
foreach ($hooks as &$scopeHooks) {
foreach ($scopeHooks as &$hookList) {
usort($hookList, [$this, 'cmpHooks']);
}
}
return $hooks;
}
/**
* @param class-string $className
*/
private function hookClassIsSuppressed(string $className): bool
{
$suppressList = $this->metadata->get(['app', 'hook', 'suppressClassNameList']) ?? [];
return in_array($className, $suppressList);
}
/**
* @param array<string, mixed> $a
* @param array<string, mixed> $b
*/
private function cmpHooks($a, $b): int
{
if ($a['order'] == $b['order']) {
return 0;
}
return ($a['order'] < $b['order']) ? -1 : 1;
}
}

View File

@@ -0,0 +1,212 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook;
use Espo\Core\Hook\Hook\AfterMassRelate;
use Espo\Core\Hook\Hook\AfterRelate;
use Espo\Core\Hook\Hook\AfterRemove;
use Espo\Core\Hook\Hook\AfterSave;
use Espo\Core\Hook\Hook\AfterUnrelate;
use Espo\Core\Hook\Hook\BeforeRemove;
use Espo\Core\Hook\Hook\BeforeSave;
use Espo\Core\Hook\Hook\LateAfterRemove;
use Espo\Core\Hook\Hook\LateAfterSave;
use Espo\ORM\Entity;
use Espo\ORM\Query\Select;
use Espo\ORM\Repository\Option\MassRelateOptions;
use Espo\ORM\Repository\Option\RelateOptions;
use Espo\ORM\Repository\Option\RemoveOptions;
use Espo\ORM\Repository\Option\SaveOptions;
use Espo\ORM\Repository\Option\UnrelateOptions;
use LogicException;
/**
* Invokes hook methods, prepares needed arguments for specific hooks.
*/
class GeneralInvoker
{
private const string HOOK_BEFORE_SAVE = 'beforeSave';
private const string HOOK_AFTER_SAVE = 'afterSave';
private const string HOOK_LATE_AFTER_SAVE = 'lateAfterSave';
private const string HOOK_BEFORE_REMOVE = 'beforeRemove';
private const string HOOK_AFTER_REMOVE = 'afterRemove';
private const string HOOK_LATE_AFTER_REMOVE = 'lateAfterRemove';
private const string HOOK_AFTER_RELATE = 'afterRelate';
private const string HOOK_AFTER_UNRELATE = 'afterUnrelate';
private const string HOOK_AFTER_MASS_RELATE = 'afterMassRelate';
/**
* @param object $hook A hook object.
* @param string $name A hook name.
* @param mixed $subject A subject.
* @param array<string, mixed> $options Options.
* @param array<string, mixed> $hookData Additional data.
*/
public function invoke(
object $hook,
string $name,
mixed $subject,
array $options,
array $hookData,
): void {
if ($name === self::HOOK_BEFORE_SAVE && $hook instanceof BeforeSave) {
if (!$subject instanceof Entity) {
throw new LogicException();
}
$hook->beforeSave($subject, SaveOptions::fromAssoc($options));
return;
}
if ($name === self::HOOK_AFTER_SAVE && $hook instanceof AfterSave) {
if (!$subject instanceof Entity) {
throw new LogicException();
}
$hook->afterSave($subject, SaveOptions::fromAssoc($options));
return;
}
if ($name === self::HOOK_LATE_AFTER_SAVE && $hook instanceof LateAfterSave) {
if (!$subject instanceof Entity) {
throw new LogicException();
}
$hook->lateAfterSave($subject, SaveOptions::fromAssoc($options));
return;
}
if ($name === self::HOOK_BEFORE_REMOVE && $hook instanceof BeforeRemove) {
if (!$subject instanceof Entity) {
throw new LogicException();
}
$hook->beforeRemove($subject, RemoveOptions::fromAssoc($options));
return;
}
if ($name === self::HOOK_AFTER_REMOVE && $hook instanceof AfterRemove) {
if (!$subject instanceof Entity) {
throw new LogicException();
}
$hook->afterRemove($subject, RemoveOptions::fromAssoc($options));
return;
}
if ($name === self::HOOK_LATE_AFTER_REMOVE && $hook instanceof LateAfterRemove) {
if (!$subject instanceof Entity) {
throw new LogicException();
}
$hook->lateAfterRemove($subject, RemoveOptions::fromAssoc($options));
return;
}
if ($name === self::HOOK_AFTER_RELATE && $hook instanceof AfterRelate) {
$relationName = $hookData['relationName'] ?? null;
$relatedEntity = $hookData['foreignEntity'] ?? null;
$columnData = $hookData['relationData'] ?? [];
if (
!$subject instanceof Entity ||
!is_string($relationName) ||
!$relatedEntity instanceof Entity
) {
throw new LogicException();
}
$hook->afterRelate(
entity: $subject,
relationName: $relationName,
relatedEntity: $relatedEntity,
columnData: $columnData,
options: RelateOptions::fromAssoc($options),
);
return;
}
if ($name === self::HOOK_AFTER_UNRELATE && $hook instanceof AfterUnrelate) {
$relationName = $hookData['relationName'] ?? null;
$relatedEntity = $hookData['foreignEntity'] ?? null;
if (
!$subject instanceof Entity ||
!is_string($relationName) ||
!$relatedEntity instanceof Entity
) {
throw new LogicException();
}
$hook->afterUnrelate(
entity: $subject,
relationName: $relationName,
relatedEntity: $relatedEntity,
options: UnrelateOptions::fromAssoc($options),
);
return;
}
if ($name === self::HOOK_AFTER_MASS_RELATE && $hook instanceof AfterMassRelate) {
$relationName = $hookData['relationName'] ?? null;
$query = $hookData['query'] ?? null;
$columnData = $hookData['relationData'] ?? []; // Not implemented currently.
if (
!$subject instanceof Entity ||
!is_string($relationName) ||
!$query instanceof Select
) {
throw new LogicException();
}
$hook->afterMassRelate(
entity: $subject,
relationName: $relationName,
query: $query,
columnData: $columnData,
options: MassRelateOptions::fromAssoc($options),
);
return;
}
$hook->$name($subject, $options, $hookData);
}
}

View File

@@ -0,0 +1,59 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Query\Select;
use Espo\ORM\Repository\Option\MassRelateOptions;
/**
* An afterMassRelate hook.
*
* @template TEntity of Entity = Entity
*/
interface AfterMassRelate
{
/**
* Processed after an entity is mass-related. Called from within a repository.
*
* @param TEntity $entity An entity.
* @param string $relationName A relation name.
* @param Select $query A select query for records to be related.
* @param array<string, mixed> $columnData Middle table role values.
* @param MassRelateOptions $options Options.
*/
public function afterMassRelate(
Entity $entity,
string $relationName,
Select $query,
array $columnData,
MassRelateOptions $options
): void;
}

View File

@@ -0,0 +1,57 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Repository\Option\RelateOptions;
/**
* An afterRelate hook.
*
* @template TEntity of Entity = Entity
*/
interface AfterRelate
{
/**
* Processed after an entity is related with another entity. Called from within a repository.
*
* @param TEntity $entity An entity.
* @param string $relationName A relation name.
* @param array<string, mixed> $columnData Middle table role values.
* @param RelateOptions $options Options.
*/
public function afterRelate(
Entity $entity,
string $relationName,
Entity $relatedEntity,
array $columnData,
RelateOptions $options
): void;
}

View File

@@ -0,0 +1,49 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Repository\Option\RemoveOptions;
/**
* An afterRemove hook.
*
* @template TEntity of Entity = Entity
*/
interface AfterRemove
{
/**
* Processed after an entity is removed from within a repository.
*
* @param TEntity $entity An entity.
* @param RemoveOptions $options Options.
*/
public function afterRemove(Entity $entity, RemoveOptions $options): void;
}

View File

@@ -0,0 +1,49 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Repository\Option\SaveOptions;
/**
* An afterSave hook.
*
* @template TEntity of Entity = Entity
*/
interface AfterSave
{
/**
* Processed after an entity is saved from within a repository.
*
* @param TEntity $entity An entity.
* @param SaveOptions $options Save options.
*/
public function afterSave(Entity $entity, SaveOptions $options): void;
}

View File

@@ -0,0 +1,55 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Repository\Option\UnrelateOptions;
/**
* An afterUnrelate hook.
*
* @template TEntity of Entity = Entity
*/
interface AfterUnrelate
{
/**
* Processed after an entity is unrelated from another entity. Called from within a repository.
*
* @param TEntity $entity An entity.
* @param string $relationName A relation name.
* @param UnrelateOptions $options Options.
*/
public function afterUnrelate(
Entity $entity,
string $relationName,
Entity $relatedEntity,
UnrelateOptions $options
): void;
}

View File

@@ -0,0 +1,49 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Repository\Option\RemoveOptions;
/**
* An beforeRemove hook.
*
* @template TEntity of Entity = Entity
*/
interface BeforeRemove
{
/**
* Processed before an entity is removed from within a repository.
*
* @param TEntity $entity An entity.
* @param RemoveOptions $options Options.
*/
public function beforeRemove(Entity $entity, RemoveOptions $options): void;
}

View File

@@ -0,0 +1,51 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Exceptions\PersistenceException;
use Espo\ORM\Repository\Option\SaveOptions;
/**
* A beforeSave hook.
*
* @template TEntity of Entity = Entity
*/
interface BeforeSave
{
/**
* Processed before an entity is saved from within a repository.
*
* @param TEntity $entity An entity.
* @param SaveOptions $options Save options.
* @throws PersistenceException
*/
public function beforeSave(Entity $entity, SaveOptions $options): void;
}

View File

@@ -0,0 +1,51 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Repository\Option\RemoveOptions;
/**
* A lateAfterRemove hook.
*
* @template TEntity of Entity = Entity
*
* @since 10.0.0
*/
interface LateAfterRemove
{
/**
* Processed after an entity is removed, after the transaction (if one is used).
*
* @param TEntity $entity An entity.
* @param RemoveOptions $options Options.
*/
public function lateAfterRemove(Entity $entity, RemoveOptions $options): void;
}

View File

@@ -0,0 +1,53 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM – Open Source CRM application.
* Copyright (C) 2014-2026 EspoCRM, Inc.
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Hook\Hook;
use Espo\ORM\Entity;
use Espo\ORM\Repository\Option\SaveOptions;
/**
* A lateAfterSave hook.
*
* @template TEntity of Entity = Entity
*
* @since 10.0.0
*/
interface LateAfterSave
{
/**
* Processed after an entity is saved, after the transaction (if one is used).
* To check whether the entity was new before save, obtain the save context
* from the options and call `isNew`.
*
* @param TEntity $entity An entity.
* @param SaveOptions $options Options.
*/
public function lateAfterSave(Entity $entity, SaveOptions $options): void;
}