Skip to content

Commit 9403b87

Browse files
committed
Introduce a flag to allow process caching enabling
1 parent 1298f8c commit 9403b87

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

src/Spryker/Shared/Oms/OmsConstants.php

+10
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@ interface OmsConstants
5151
* @var string
5252
*/
5353
public const PROCESS_CACHE_PATH = 'OMS:PROCESS_CACHE_PATH';
54+
55+
/**
56+
* Specification:
57+
* - Defines if automatic processes caching is enabled,
58+
*
59+
* @api
60+
*
61+
* @var string
62+
*/
63+
public const ENABLE_PROCESS_CACHE = 'OMS:ENABLE_PROCESS_CACHE';
5464
}

src/Spryker/Zed/Oms/Business/OmsBusinessFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function createOrderStateMachineBuilder()
133133
$this->getConfig()->getProcessDefinitionLocation(),
134134
$this->createProcessCacheReader(),
135135
$this->createProcessCacheWriter(),
136+
$this->getConfig(),
136137
$this->getConfig()->getSubProcessPrefixDelimiter(),
137138
);
138139
}

src/Spryker/Zed/Oms/Business/OrderStateMachine/Builder.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Spryker\Zed\Oms\Business\Process\TransitionInterface;
1717
use Spryker\Zed\Oms\Business\Reader\ProcessCacheReaderInterface;
1818
use Spryker\Zed\Oms\Business\Writer\ProcessCacheWriterInterface;
19+
use Spryker\Zed\Oms\OmsConfig;
1920
use Symfony\Component\Finder\Finder as SymfonyFinder;
2021

2122
class Builder implements BuilderInterface
@@ -70,6 +71,11 @@ class Builder implements BuilderInterface
7071
*/
7172
protected ProcessCacheWriterInterface $processCacheWriter;
7273

74+
/**
75+
* @var \Spryker\Zed\Oms\OmsConfig
76+
*/
77+
protected OmsConfig $config;
78+
7379
/**
7480
* @param \Spryker\Zed\Oms\Business\Process\EventInterface $event
7581
* @param \Spryker\Zed\Oms\Business\Process\StateInterface $state
@@ -78,6 +84,7 @@ class Builder implements BuilderInterface
7884
* @param array|string $processDefinitionLocation
7985
* @param \Spryker\Zed\Oms\Business\Reader\ProcessCacheReaderInterface $processCacheReader
8086
* @param \Spryker\Zed\Oms\Business\Writer\ProcessCacheWriterInterface $processCacheWriter
87+
* @param \Spryker\Zed\Oms\OmsConfig $config,
8188
* @param string $subProcessPrefixDelimiter
8289
*/
8390
public function __construct(
@@ -88,6 +95,7 @@ public function __construct(
8895
$processDefinitionLocation,
8996
ProcessCacheReaderInterface $processCacheReader,
9097
ProcessCacheWriterInterface $processCacheWriter,
98+
OmsConfig $config,
9199
$subProcessPrefixDelimiter = ' - '
92100
) {
93101
$this->event = $event;
@@ -96,6 +104,7 @@ public function __construct(
96104
$this->process = $process;
97105
$this->processCacheReader = $processCacheReader;
98106
$this->processCacheWriter = $processCacheWriter;
107+
$this->config = $config;
99108
$this->subProcessPrefixDelimiter = $subProcessPrefixDelimiter;
100109

101110
$this->setProcessDefinitionLocation($processDefinitionLocation);
@@ -122,7 +131,9 @@ public function createProcess($processName)
122131

123132
static::$processBuffer[$processName] = $mainProcess;
124133

125-
$this->processCacheWriter->cacheProcess($mainProcess, $processName);
134+
if ($this->config->getProcessCacheEnabled()) {
135+
$this->processCacheWriter->cacheProcess($mainProcess, $processName);
136+
}
126137

127138
return static::$processBuffer[$processName];
128139
}

src/Spryker/Zed/Oms/OmsConfig.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,20 @@ public function getProcessCachePath(): string
200200

201201
/**
202202
* Specification:
203-
* - Returns process cache file permission.
203+
* - Defines if automatic processes caching is enabled.
204+
*
205+
* @api
204206
*
207+
* @return bool
208+
*/
209+
public function getProcessCacheEnabled(): bool
210+
{
211+
return (bool)$this->get(OmsConstants::ENABLE_PROCESS_CACHE, true);
212+
}
213+
214+
/**
215+
* Specification:
216+
* - Returns process cache file permission.
205217
* @api
206218
*
207219
* @return int

0 commit comments

Comments
 (0)