EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Webhook update global event
Yuriifb6ffd7f0dcb
diff --git a/application/Espo/Core/Webhook/Events/UpdateGlobal.php b/application/Espo/Core/Webhook/Events/UpdateGlobal.phpnew file mode 100644index 0000000000..206fe6a381--- /dev/null+++ b/application/Espo/Core/Webhook/Events/UpdateGlobal.php@@ -0,0 +1,46 @@+<?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\Webhook\Events;++use Espo\Core\Utils\Event\CrossInstanceEvent;+use stdClass;++class UpdateGlobal implements CrossInstanceEvent+{+ public static function fromRaw(stdClass $payload): CrossInstanceEvent+ {+ return new self();+ }++ public function toRaw(): stdClass+ {+ return (object) [];+ }+}diff --git a/application/Espo/Core/Webhook/Manager.php b/application/Espo/Core/Webhook/Manager.phpindex d78e32ea99..1830cb640a 100644--- a/application/Espo/Core/Webhook/Manager.php+++ b/application/Espo/Core/Webhook/Manager.php@@ -34,8 +34,11 @@ use Espo\Core\ORM\Entity;use Espo\Core\ORM\EntityManager;use Espo\Core\Utils\Cache\DataCacheAccess;use Espo\Core\Utils\Config;+use Espo\Core\Utils\Event\Context;+use Espo\Core\Utils\Event\EventDispatcher;use Espo\Core\Utils\FieldUtil;use Espo\Core\Utils\Log;+use Espo\Core\Webhook\Events\UpdateGlobal;use Espo\Entities\Webhook;use Espo\Entities\WebhookEventQueueItem;use Espo\ORM\Name\Attribute;@@ -69,12 +72,21 @@ class Managerprivate FieldUtil $fieldUtil,private Log $log,private DataCacheAccess $dataCacheAccess,+ private EventDispatcher $eventDispatcher,) {$this->dataCacheAccess->init(key: $this->cacheKey,loader: fn () => $this->buildData(),);++ $this->eventDispatcher->subscribe(UpdateGlobal::class, function (UpdateGlobal $event, Context $context) {+ if ($context->isLocal) {+ return;+ }++ $this->dataCacheAccess->reset();+ });}/**@@ -114,6 +126,8 @@ class Manager$this->dataCacheAccess->set($data);$this->dataCacheAccess->store();++ $this->eventDispatcher->dispatch(new UpdateGlobal());}/**@@ -140,6 +154,8 @@ class Manager$this->dataCacheAccess->set($data);$this->dataCacheAccess->store();++ $this->eventDispatcher->dispatch(new UpdateGlobal());}private function eventExists(string $event): bool