Skip to content

EspoCRM – Open Source CRM Application

Pipeline data provider service

Yuriicfd776155d56
diff --git a/application/Espo/Binding.php b/application/Espo/Binding.php
index a6b2a78823..3c6ed8a5f6 100644
--- a/application/Espo/Binding.php
+++ b/application/Espo/Binding.php
@@ -272,6 +272,11 @@ class Binding implements BindingProcessor
'Espo\\Core\\Utils\\Event\\EventDispatcherTransport',
'eventDispatcherTransport'
);
+
+ $binder->bindService(
+ 'Espo\\Tools\\Pipeline\\PipelineDataProvider',
+ 'pipelineDataProvider'
+ );
}
private function bindCore(Binder $binder): void
diff --git a/application/Espo/Resources/metadata/app/containerServices.json b/application/Espo/Resources/metadata/app/containerServices.json
index 172a4a2eaf..2e9e64515f 100644
--- a/application/Espo/Resources/metadata/app/containerServices.json
+++ b/application/Espo/Resources/metadata/app/containerServices.json
@@ -97,5 +97,8 @@
},
"eventDispatcherTransport": {
"loaderClassName": "Espo\\Core\\Utils\\Event\\EventDispatcherTransportLoader"
+ },
+ "pipelineDataProvider": {
+ "className": "Espo\\Tools\\Pipeline\\PipelineDataProvider"
}
}
diff --git a/application/Espo/Tools/Pipeline/CacheClearer.php b/application/Espo/Tools/Pipeline/CacheClearer.php
index 0e877c70a5..f95d94a81a 100644
--- a/application/Espo/Tools/Pipeline/CacheClearer.php
+++ b/application/Espo/Tools/Pipeline/CacheClearer.php
@@ -30,7 +30,9 @@
namespace Espo\Tools\Pipeline;
use Espo\Core\Utils\DataCache;
+use Espo\Core\Utils\Event\EventDispatcher;
use Espo\Core\WebSocket\Submission;
+use Espo\Tools\Pipeline\Events\UpdateGlobal;
class CacheClearer
{
@@ -39,11 +41,13 @@ class CacheClearer
public function __construct(
private DataCache $dataCache,
private Submission $submission,
+ private EventDispatcher $eventDispatcher,
) {}
public function clear(): void
{
$this->dataCache->clear(self::CACHE_KEY);
+ $this->eventDispatcher->dispatch(new UpdateGlobal());
$this->submission->submit('appParamsUpdate');
}
}
diff --git a/application/Espo/Tools/Pipeline/Events/UpdateGlobal.php b/application/Espo/Tools/Pipeline/Events/UpdateGlobal.php
new file mode 100644
index 0000000000..9d47976188
--- /dev/null
+++ b/application/Espo/Tools/Pipeline/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\Tools\Pipeline\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/Tools/Pipeline/PipelineDataProvider.php b/application/Espo/Tools/Pipeline/PipelineDataProvider.php
index 19852ff7d2..22c86eaaf2 100644
--- a/application/Espo/Tools/Pipeline/PipelineDataProvider.php
+++ b/application/Espo/Tools/Pipeline/PipelineDataProvider.php
@@ -31,6 +31,7 @@ namespace Espo\Tools\Pipeline;
use Espo\Core\Utils\Config\SystemConfig;
use Espo\Core\Utils\DataCache;
+use Espo\Core\Utils\Event\EventDispatcher;
use Espo\Core\Utils\Log;
use Espo\Core\Utils\Metadata;
use Espo\Entities\Pipeline;
@@ -38,6 +39,7 @@ use Espo\Entities\PipelineStage;
use Espo\ORM\EntityManager;
use Espo\Tools\Pipeline\Data\PipelineData;
use Espo\Tools\Pipeline\Data\StageData;
+use Espo\Tools\Pipeline\Events\UpdateGlobal;
use stdClass;
use Throwable;
@@ -46,19 +48,33 @@ class PipelineDataProvider
private const int LIMIT = 100;
private const string CACHE_KEY = 'pipelines';
+ /**
+ * @var ?array<string, PipelineData[]>
+ */
+ private ?array $data = null;
+
public function __construct(
private Metadata $metadata,
private EntityManager $entityManager,
private SystemConfig $systemConfig,
private DataCache $dataCache,
private Log $log,
- ) {}
+ EventDispatcher $eventDispatcher,
+ ) {
+ $eventDispatcher->subscribe(UpdateGlobal::class, function () {
+ $this->data = null;
+ });
+ }
/**
* @return array<string, PipelineData[]>
*/
public function get(): array
{
+ if ($this->data !== null) {
+ return $this->data;
+ }
+
$data = null;
$store = false;
@@ -76,6 +92,8 @@ class PipelineDataProvider
$this->storeCache($data);
}
+ $this->data = $data;
+
return $data;
}