1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/old-town/workflow-doctrine |
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
namespace OldTown\Workflow\Spi\Doctrine\Entity; |
7
|
|
|
|
8
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
9
|
|
|
use Doctrine\ORM\Mapping as ORM; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class WorkflowName |
14
|
|
|
* |
15
|
|
|
* @ORM\Entity() |
16
|
|
|
* @ORM\Table(name="wf_entry") |
17
|
|
|
* @ORM\InheritanceType(value="SINGLE_TABLE") |
18
|
|
|
* @ORM\DiscriminatorColumn(name="type", type="string") |
19
|
|
|
* |
20
|
|
|
* @package OldTown\Workflow\Spi\Doctrine |
21
|
|
|
*/ |
22
|
|
|
abstract class AbstractEntry implements EntryInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @ORM\Id() |
26
|
|
|
* @ORM\Column(name="id", type="integer") |
27
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
28
|
|
|
* |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
protected $id; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @ORM\Column(name="workflow_name", type="string", length=60) |
35
|
|
|
* |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $workflowName; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @ORM\Column(name="state", type="integer") |
43
|
|
|
* |
44
|
|
|
* |
45
|
|
|
* @var integer |
46
|
|
|
*/ |
47
|
|
|
protected $state; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Шаги привязанные к процессу wf |
51
|
|
|
* |
52
|
|
|
* @ORM\OneToMany(targetEntity="Step", mappedBy="entry") |
53
|
|
|
* |
54
|
|
|
* @var StepInterface |
55
|
|
|
*/ |
56
|
|
|
protected $steps; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* AbstractEntry constructor. |
60
|
|
|
*/ |
61
|
|
|
public function __construct() |
62
|
|
|
{ |
63
|
|
|
$this->steps = new ArrayCollection(); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
public function getId() |
70
|
|
|
{ |
71
|
|
|
return $this->id; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param string $id |
76
|
|
|
* |
77
|
|
|
* @return $this |
78
|
|
|
*/ |
79
|
|
|
public function setId($id) |
80
|
|
|
{ |
81
|
|
|
$this->id = (integer)$id; |
|
|
|
|
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
public function getWorkflowName() |
90
|
|
|
{ |
91
|
|
|
return $this->workflowName; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $workflowName |
96
|
|
|
* |
97
|
|
|
* @return $this |
98
|
|
|
*/ |
99
|
|
|
public function setWorkflowName($workflowName) |
100
|
|
|
{ |
101
|
|
|
$this->workflowName = (string)$workflowName; |
102
|
|
|
|
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return integer |
108
|
|
|
*/ |
109
|
|
|
public function getState() |
110
|
|
|
{ |
111
|
|
|
return $this->state; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param integer $state |
116
|
|
|
* |
117
|
|
|
* @return $this |
118
|
|
|
*/ |
119
|
|
|
public function setState($state) |
120
|
|
|
{ |
121
|
|
|
$this->state = (integer)$state; |
122
|
|
|
|
123
|
|
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Определяет иницилазирован ли процесс workflow |
128
|
|
|
* |
129
|
|
|
* @return bool |
130
|
|
|
*/ |
131
|
|
|
public function isInitialized() |
132
|
|
|
{ |
133
|
|
|
return $this->state > 0; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return ArrayCollection|StepInterface[] |
139
|
|
|
*/ |
140
|
|
|
public function getSteps() |
141
|
|
|
{ |
142
|
|
|
return $this->steps; |
|
|
|
|
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param StepInterface $step |
147
|
|
|
* |
148
|
|
|
* @return $this |
149
|
|
|
*/ |
150
|
|
|
public function addCurrentStep(StepInterface $step) |
151
|
|
|
{ |
152
|
|
|
$step->setEntry($this); |
153
|
|
|
if (!$this->getSteps()->contains($step)) { |
|
|
|
|
154
|
|
|
$this->getSteps()->add($step); |
|
|
|
|
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..