1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/old-town/old-town-workflow |
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
namespace OldTown\Workflow\Engine; |
7
|
|
|
|
8
|
|
|
use OldTown\PropertySet\PropertySetInterface; |
9
|
|
|
use OldTown\Workflow\Exception\InternalWorkflowException; |
10
|
|
|
use OldTown\Workflow\Exception\WorkflowException; |
11
|
|
|
use OldTown\Workflow\Loader\FunctionDescriptor; |
12
|
|
|
use OldTown\Workflow\TransientVars\TransientVarsInterface; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class Functions |
17
|
|
|
* |
18
|
|
|
* @package OldTown\Workflow\Engine |
19
|
|
|
*/ |
20
|
|
|
class Functions extends AbstractEngine implements FunctionsInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @param FunctionDescriptor $function |
24
|
|
|
* @param TransientVarsInterface $transientVars |
25
|
|
|
* @param PropertySetInterface $ps |
26
|
|
|
* |
27
|
|
|
* @throws WorkflowException |
28
|
|
|
* @throws InternalWorkflowException |
29
|
|
|
*/ |
30
|
4 |
|
public function executeFunction(FunctionDescriptor $function, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
31
|
|
|
{ |
32
|
4 |
|
if (null !== $function) { |
33
|
4 |
|
$type = $function->getType(); |
34
|
|
|
|
35
|
4 |
|
$argsOriginal = $function->getArgs(); |
36
|
|
|
|
37
|
4 |
|
$workflowManager = $this->getWorkflowManager(); |
38
|
|
|
|
39
|
4 |
|
$args = $workflowManager->getEngineManager()->getArgsEngine()->prepareArgs($argsOriginal, $transientVars, $ps); |
40
|
|
|
|
41
|
4 |
|
$provider = $workflowManager->getResolver()->getFunction($type, $args); |
42
|
|
|
|
43
|
4 |
|
if (null === $provider) { |
44
|
1 |
|
$workflowManager->getContext()->setRollbackOnly(); |
45
|
|
|
$errMsg = 'Не загружен провайдер для функции'; |
46
|
|
|
throw new WorkflowException($errMsg); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
try { |
50
|
4 |
|
$provider->execute($transientVars, $args, $ps); |
51
|
4 |
|
} catch (WorkflowException $e) { |
52
|
|
|
$workflowManager->getContext()->setRollbackOnly(); |
53
|
|
|
/** @var WorkflowException $e*/ |
54
|
|
|
throw $e; |
55
|
|
|
} |
56
|
4 |
|
} |
57
|
4 |
|
} |
58
|
|
|
} |
59
|
|
|
|