-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathProcess.php
More file actions
69 lines (62 loc) · 1.81 KB
/
Process.php
File metadata and controls
69 lines (62 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace ProcessMaker\Bpmn;
use Illuminate\Support\Facades\Cache;
use ProcessMaker\Nayra\Bpmn\Models\Process as ModelsProcess;
class Process extends ModelsProcess
{
/**
* Get a property.
*
* @param string $name
* @param mixed $default
*
* @return mixed
*/
public function getProperty($name, $default = null)
{
if ($name === 'conditionals') {
$key = '_process_' . $this->getOwnerDocument()->getModel()->getKey();
$properties = Cache::store('global_variables')->get($key, []);
return $properties[$name] ?? $default;
} else {
return parent::getProperty($name, $default);
}
}
/**
* Set a property.
*
* @param string $name
* @param mixed $value
*
* @return $this
*/
public function setProperty($name, $value)
{
if ($name === 'conditionals') {
$key = '_process_' . $this->getOwnerDocument()->getModel()->getKey();
$properties = Cache::store('global_variables')->get($key, []);
$properties[$name] = $value;
try {
Cache::store('global_variables')->forget($key);
Cache::store('global_variables')->forever($key, $properties);
} catch (\Throwable $e) {
\Log::error($e->getMessage());
if (in_array('22001', $e->errorInfo)) {
Cache::store('global_variables')->forget($key);
}
}
return $this;
} else {
return parent::setProperty($name, $value);
}
}
/**
* Return true if the process is not persistent
*
* @return bool
*/
public function isNonPersistent()
{
return strpos($this->getId(), 'non_persistent') !== false;
}
}