|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kaliop\eZWorkflowEngineBundle\API\Value; |
|
4
|
|
|
|
|
5
|
|
|
use Kaliop\eZMigrationBundle\API\Value\MigrationDefinition; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @property-read string $signalName |
|
9
|
|
|
* @property-read string $runAs use false for 'current user' |
|
10
|
|
|
* @property-read bool $useTransaction |
|
11
|
|
|
* @property-read bool $avoidRecursion |
|
12
|
|
|
*/ |
|
13
|
|
|
class WorkflowDefinition extends MigrationDefinition |
|
14
|
|
|
{ |
|
15
|
|
|
const MANIFEST_STEP_TYPE= 'workflow'; |
|
16
|
|
|
const MANIFEST_SIGNAL_ELEMENT= 'signal'; |
|
17
|
|
|
const MANIFEST_RUNAS_ELEMENT= 'run_as'; |
|
18
|
|
|
const MANIFEST_USETRANSACTION_ELEMENT= 'transaction'; |
|
19
|
|
|
const MANIFEST_AVOIDRECURSION_ELEMENT= 'avoid_recursion'; |
|
20
|
|
|
|
|
21
|
|
|
protected $signalName; |
|
22
|
|
|
// unlike migrations, workflows default to run as current user |
|
23
|
|
|
protected $runAs = false; |
|
24
|
|
|
protected $useTransaction = false; |
|
25
|
|
|
protected $avoidRecursion; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* WorkflowDefinition constructor. |
|
29
|
|
|
* @param string $name |
|
30
|
|
|
* @param string $path |
|
31
|
|
|
* @param string $rawDefinition |
|
32
|
|
|
* @param int $status |
|
33
|
|
|
* @param \Kaliop\eZMigrationBundle\API\Value\MigrationStep[]|\Kaliop\eZMigrationBundle\API\Collection\MigrationStepsCollection $steps |
|
34
|
|
|
* @param string $parsingError |
|
35
|
|
|
* @param string $signalName |
|
36
|
|
|
* @param string|int|false|null $runAs if false will use the current user; if null will use hardcoded 14; string for login or user id |
|
37
|
|
|
* @param bool $useTransaction |
|
38
|
|
|
* @throws \Exception |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct($name, $path, $rawDefinition, $status = 0, $steps = array(), $parsingError = null, |
|
41
|
|
|
$signalName = null, $runAs = false, $useTransaction = false, $avoidRecursion = false) |
|
42
|
|
|
{ |
|
43
|
|
|
if ($status == MigrationDefinition::STATUS_PARSED && $signalName == null) { |
|
|
|
|
|
|
44
|
|
|
throw new \Exception("Can not create a parsed Workflow definition without a corresponding signal"); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$this->signalName = $signalName; |
|
|
|
|
|
|
48
|
|
|
$this->runAs = $runAs; |
|
|
|
|
|
|
49
|
|
|
$this->useTransaction = $useTransaction; |
|
|
|
|
|
|
50
|
|
|
$this->avoidRecursion = $avoidRecursion; |
|
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
parent::__construct( |
|
53
|
|
|
$name, $path, $rawDefinition, $status, $steps, $parsingError |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Allow the class to be serialized to php using var_export |
|
59
|
|
|
* @param array $data |
|
60
|
|
|
* @return static |
|
61
|
|
|
*/ |
|
62
|
|
|
public static function __set_state(array $data) |
|
63
|
|
|
{ |
|
64
|
|
|
return new static( |
|
65
|
|
|
$data['name'], |
|
66
|
|
|
$data['path'], |
|
67
|
|
|
$data['rawDefinition'], |
|
68
|
|
|
$data['status'], |
|
69
|
|
|
$data['steps'], |
|
70
|
|
|
$data['parsingError'], |
|
71
|
|
|
$data['signalName'], |
|
72
|
|
|
$data['runAs'], |
|
73
|
|
|
$data['useTransaction'], |
|
74
|
|
|
$data['avoidRecursion'] |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|