Skip to content

EspoCRM – Open Source CRM Application

rebuild on stream enabling

Yuri Kuznetsov4ae930544e96
diff --git a/application/Espo/Resources/metadata/app/entityManager.json b/application/Espo/Resources/metadata/app/entityManager.json
index 8258bda9b3..212cacc3c4 100644
--- a/application/Espo/Resources/metadata/app/entityManager.json
+++ b/application/Espo/Resources/metadata/app/entityManager.json
@@ -10,6 +10,7 @@
],
"updateHookClassNameList": [
"Espo\\Tools\\EntityManager\\Hook\\Hooks\\AssignedUsersUpdateHook",
- "Espo\\Tools\\EntityManager\\Hook\\Hooks\\CollaboratorsUpdateHook"
+ "Espo\\Tools\\EntityManager\\Hook\\Hooks\\CollaboratorsUpdateHook",
+ "Espo\\Tools\\EntityManager\\Hook\\Hooks\\StreamUpdateHook"
]
}
diff --git a/application/Espo/Tools/EntityManager/Hook/Hooks/StreamUpdateHook.php b/application/Espo/Tools/EntityManager/Hook/Hooks/StreamUpdateHook.php
new file mode 100644
index 0000000000..1d7162aac2
--- /dev/null
+++ b/application/Espo/Tools/EntityManager/Hook/Hooks/StreamUpdateHook.php
@@ -0,0 +1,57 @@
+<?php
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM – Open Source CRM application.
+ * Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
+ * 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\Tools\EntityManager\Hook\Hooks;
+
+use Espo\Core\DataManager;
+use Espo\Core\Exceptions\Error;
+use Espo\Tools\EntityManager\Hook\UpdateHook;
+use Espo\Tools\EntityManager\Params;
+
+/**
+ * @noinspection PhpUnused
+ */
+class StreamUpdateHook implements UpdateHook
+{
+ private const PARAM = 'stream';
+
+ public function __construct(
+ private DataManager $dataManager,
+ ) {}
+
+ /**
+ * @throws Error
+ */
+ public function process(Params $params, Params $previousParams): void
+ {
+ if ($params->get(self::PARAM) && !$previousParams->get(self::PARAM)) {
+ $this->dataManager->rebuild([$params->getName()]);
+ }
+ }
+}