diff --git a/application/Espo/Core/Repositories/Database.php b/application/Espo/Core/Repositories/Database.php index a2abccebf7..a0e20ad688 100644 --- a/application/Espo/Core/Repositories/Database.php +++ b/application/Espo/Core/Repositories/Database.php @@ -90,9 +90,11 @@ class Database extends RDBRepository $this->applicationState = $applicationState; $this->recordIdGenerator = $recordIdGenerator; + $hooksDisabled = $this->hooksDisabled || $metadata->get("entityDefs.$entityType.hooksDisabled"); + $hookMediator = null; - if (!$this->hooksDisabled) { + if (!$hooksDisabled) { $hookMediator = new HookMediator($hookManager); } diff --git a/application/Espo/Repositories/ActionHistoryRecord.php b/application/Espo/Repositories/ActionHistoryRecord.php deleted file mode 100644 index db9e988350..0000000000 --- a/application/Espo/Repositories/ActionHistoryRecord.php +++ /dev/null @@ -1,38 +0,0 @@ -. - * - * 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\Repositories; - -/** - * @extends \Espo\Core\Repositories\Database<\Espo\Entities\ActionHistoryRecord> - */ -class ActionHistoryRecord extends \Espo\Core\Repositories\Database -{ - protected $hooksDisabled = true; -} diff --git a/application/Espo/Repositories/ArrayValue.php b/application/Espo/Repositories/ArrayValue.php index ba2c466658..15e9d08913 100644 --- a/application/Espo/Repositories/ArrayValue.php +++ b/application/Espo/Repositories/ArrayValue.php @@ -42,8 +42,6 @@ use LogicException; */ class ArrayValue extends Database { - protected $hooksDisabled = true; - private const ITEM_MAX_LENGTH = 100; public function storeEntityAttribute(CoreEntity $entity, string $attribute, bool $populateMode = false): void diff --git a/application/Espo/Repositories/AuthFailLogRecord.php b/application/Espo/Repositories/AuthFailLogRecord.php deleted file mode 100644 index d8ec7d5f9f..0000000000 --- a/application/Espo/Repositories/AuthFailLogRecord.php +++ /dev/null @@ -1,38 +0,0 @@ -. - * - * 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\Repositories; - -/** - * @extends \Espo\Core\Repositories\Database<\Espo\Core\ORM\Entity> - */ -class AuthFailLogRecord extends \Espo\Core\Repositories\Database -{ - protected $hooksDisabled = true; -} diff --git a/application/Espo/Repositories/AuthLogRecord.php b/application/Espo/Repositories/AuthLogRecord.php deleted file mode 100644 index 57886eea1b..0000000000 --- a/application/Espo/Repositories/AuthLogRecord.php +++ /dev/null @@ -1,38 +0,0 @@ -. - * - * 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\Repositories; - -/** - * @extends \Espo\Core\Repositories\Database<\Espo\Entities\AuthLogRecord> - */ -class AuthLogRecord extends \Espo\Core\Repositories\Database -{ - protected $hooksDisabled = true; -} diff --git a/application/Espo/Repositories/AuthToken.php b/application/Espo/Repositories/AuthToken.php deleted file mode 100644 index 5482aba162..0000000000 --- a/application/Espo/Repositories/AuthToken.php +++ /dev/null @@ -1,38 +0,0 @@ -. - * - * 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\Repositories; - -/** - * @extends \Espo\Core\Repositories\Database<\Espo\Entities\AuthToken> - */ -class AuthToken extends \Espo\Core\Repositories\Database -{ - protected $hooksDisabled = true; -} diff --git a/application/Espo/Repositories/EmailAddress.php b/application/Espo/Repositories/EmailAddress.php index fafae6f43a..2406862c30 100644 --- a/application/Espo/Repositories/EmailAddress.php +++ b/application/Espo/Repositories/EmailAddress.php @@ -51,8 +51,6 @@ class EmailAddress extends Database implements use Di\AclManagerSetter; use Di\ConfigSetter; - protected $hooksDisabled = true; - private const LOOKUP_SMALL_MAX_SIZE = 20; private const LOOKUP_MAX_SIZE = 50; diff --git a/application/Espo/Repositories/Extension.php b/application/Espo/Repositories/Extension.php deleted file mode 100644 index 613efdbdeb..0000000000 --- a/application/Espo/Repositories/Extension.php +++ /dev/null @@ -1,38 +0,0 @@ -. - * - * 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\Repositories; - -/** - * @extends \Espo\Core\Repositories\Database<\Espo\Entities\Extension> - */ -class Extension extends \Espo\Core\Repositories\Database -{ - protected $hooksDisabled = true; -} diff --git a/application/Espo/Repositories/Job.php b/application/Espo/Repositories/Job.php index d1aa60ea40..0e05f854d6 100644 --- a/application/Espo/Repositories/Job.php +++ b/application/Espo/Repositories/Job.php @@ -44,8 +44,6 @@ class Job extends Database implements { use Di\ConfigSetter; - protected $hooksDisabled = true; - /** * @param JobEntity $entity */ diff --git a/application/Espo/Repositories/NextNumber.php b/application/Espo/Repositories/NextNumber.php deleted file mode 100644 index a8a768308a..0000000000 --- a/application/Espo/Repositories/NextNumber.php +++ /dev/null @@ -1,40 +0,0 @@ -. - * - * 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\Repositories; - -use Espo\Core\Repositories\Database; - -/** - * @extends Database<\Espo\Entities\NextNumber> - */ -class NextNumber extends Database -{ - protected $hooksDisabled = true; -} diff --git a/application/Espo/Repositories/PhoneNumber.php b/application/Espo/Repositories/PhoneNumber.php index 7955f7b77c..3aa1792f46 100644 --- a/application/Espo/Repositories/PhoneNumber.php +++ b/application/Espo/Repositories/PhoneNumber.php @@ -52,8 +52,6 @@ class PhoneNumber extends Database implements use Di\AclManagerSetter; use Di\ConfigSetter; - protected $hooksDisabled = true; - private const ERASED_PREFIX = 'ERASED:'; private const LOOKUP_SMALL_MAX_SIZE = 20; diff --git a/application/Espo/Repositories/UniqueId.php b/application/Espo/Repositories/UniqueId.php index 58636fba51..076fd9e00e 100644 --- a/application/Espo/Repositories/UniqueId.php +++ b/application/Espo/Repositories/UniqueId.php @@ -39,8 +39,6 @@ use Espo\Core\Repositories\Database; */ class UniqueId extends Database { - protected $hooksDisabled = true; - public function getNew(): Entity { $entity = parent::getNew(); diff --git a/application/Espo/Repositories/Webhook.php b/application/Espo/Repositories/Webhook.php index 685846b232..c2594764d4 100644 --- a/application/Espo/Repositories/Webhook.php +++ b/application/Espo/Repositories/Webhook.php @@ -38,8 +38,6 @@ use Espo\Core\Repositories\Database; */ class Webhook extends Database { - protected $hooksDisabled = true; - protected function beforeSave(Entity $entity, array $options = []) { if ($entity->isNew()) { diff --git a/application/Espo/Resources/metadata/entityDefs/ActionHistoryRecord.json b/application/Espo/Resources/metadata/entityDefs/ActionHistoryRecord.json index 11ca24c2a3..d8497b3db2 100644 --- a/application/Espo/Resources/metadata/entityDefs/ActionHistoryRecord.json +++ b/application/Espo/Resources/metadata/entityDefs/ActionHistoryRecord.json @@ -72,5 +72,6 @@ "order": "asc", "textFilterFields": ["ipAddress", "userName"], "countDisabled": true - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/ArrayValue.json b/application/Espo/Resources/metadata/entityDefs/ArrayValue.json index 75970d1e62..f3e937ef93 100644 --- a/application/Espo/Resources/metadata/entityDefs/ArrayValue.json +++ b/application/Espo/Resources/metadata/entityDefs/ArrayValue.json @@ -20,5 +20,6 @@ "entityValue": { "columns": ["entityType", "entityId", "value"] } - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/AuthLogRecord.json b/application/Espo/Resources/metadata/entityDefs/AuthLogRecord.json index 7c02fa9ca8..399baf2fb0 100644 --- a/application/Espo/Resources/metadata/entityDefs/AuthLogRecord.json +++ b/application/Espo/Resources/metadata/entityDefs/AuthLogRecord.json @@ -105,5 +105,6 @@ "requestTime": { "columns": ["requestTime"] } - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/AuthToken.json b/application/Espo/Resources/metadata/entityDefs/AuthToken.json index 5b1e9aebcd..d777cba9f3 100644 --- a/application/Espo/Resources/metadata/entityDefs/AuthToken.json +++ b/application/Espo/Resources/metadata/entityDefs/AuthToken.json @@ -74,5 +74,6 @@ "token": { "columns": ["token", "deleted"] } - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/EmailAddress.json b/application/Espo/Resources/metadata/entityDefs/EmailAddress.json index 03f30481ec..99485c8bab 100644 --- a/application/Espo/Resources/metadata/entityDefs/EmailAddress.json +++ b/application/Espo/Resources/metadata/entityDefs/EmailAddress.json @@ -21,10 +21,10 @@ "notStorable": true } }, - "links": { - }, + "links": {}, "collection": { "orderBy": "name", "order": "asc" - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/Extension.json b/application/Espo/Resources/metadata/entityDefs/Extension.json index 9f35d19eeb..f680f1760a 100644 --- a/application/Espo/Resources/metadata/entityDefs/Extension.json +++ b/application/Espo/Resources/metadata/entityDefs/Extension.json @@ -55,5 +55,6 @@ "collection": { "orderBy": "createdAt", "order": "desc" - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/Job.json b/application/Espo/Resources/metadata/entityDefs/Job.json index 4113615012..5c2c315e0e 100644 --- a/application/Espo/Resources/metadata/entityDefs/Job.json +++ b/application/Espo/Resources/metadata/entityDefs/Job.json @@ -133,5 +133,6 @@ "statusScheduledJobId": { "columns": ["status", "scheduledJobId"] } - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/NextNumber.json b/application/Espo/Resources/metadata/entityDefs/NextNumber.json index c5d443e1e2..7bf2a03933 100644 --- a/application/Espo/Resources/metadata/entityDefs/NextNumber.json +++ b/application/Espo/Resources/metadata/entityDefs/NextNumber.json @@ -18,5 +18,6 @@ "entityTypeFieldName": { "columns": ["entityType", "fieldName"] } - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/PhoneNumber.json b/application/Espo/Resources/metadata/entityDefs/PhoneNumber.json index 630f8033f4..2eb2b0d85c 100644 --- a/application/Espo/Resources/metadata/entityDefs/PhoneNumber.json +++ b/application/Espo/Resources/metadata/entityDefs/PhoneNumber.json @@ -25,10 +25,10 @@ "notStorable": true } }, - "links": { - }, + "links": {}, "collection": { "orderBy": "name", "order": "asc" - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/UniqueId.json b/application/Espo/Resources/metadata/entityDefs/UniqueId.json index 09aca8d580..44dd8e496e 100644 --- a/application/Espo/Resources/metadata/entityDefs/UniqueId.json +++ b/application/Espo/Resources/metadata/entityDefs/UniqueId.json @@ -35,5 +35,6 @@ "collection": { "orderBy": "createdAt", "order": "desc" - } + }, + "hooksDisabled": true } diff --git a/application/Espo/Resources/metadata/entityDefs/Webhook.json b/application/Espo/Resources/metadata/entityDefs/Webhook.json index 3a2bf35ed6..00335a6e02 100644 --- a/application/Espo/Resources/metadata/entityDefs/Webhook.json +++ b/application/Espo/Resources/metadata/entityDefs/Webhook.json @@ -93,5 +93,6 @@ "entityTypeField": { "columns": ["entityType", "field"] } - } + }, + "hooksDisabled": true } diff --git a/schema/metadata/entityDefs.json b/schema/metadata/entityDefs.json index e2171c0699..b94e1728c5 100644 --- a/schema/metadata/entityDefs.json +++ b/schema/metadata/entityDefs.json @@ -84,6 +84,10 @@ "type": "boolean", "description": "Do not add the `deleted` attribute." }, + "hooksDisabled": { + "type": "boolean", + "description": "Disable hooks. As of v8.2." + }, "entityClassName": { "type": "string", "description": "An entity. Should implement Espo\\ORM\\Entity. Usually should extend Espo\\Core\\ORM\\Entity. As of v8.2."