Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like AbstractWorkflow often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AbstractWorkflow, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
50 | abstract class AbstractWorkflow implements WorkflowInterface |
||
51 | { |
||
52 | /** |
||
53 | * @var WorkflowContextInterface |
||
54 | */ |
||
55 | protected $context; |
||
56 | |||
57 | /** |
||
58 | * @var ConfigurationInterface |
||
59 | */ |
||
60 | protected $configuration; |
||
61 | |||
62 | /** |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $stateCache = []; |
||
67 | |||
68 | /** |
||
69 | * @var TypeResolverInterface |
||
70 | */ |
||
71 | protected $typeResolver; |
||
72 | |||
73 | /** |
||
74 | * Логер |
||
75 | * |
||
76 | * @var LoggerInterface |
||
77 | */ |
||
78 | protected $log; |
||
79 | |||
80 | /** |
||
81 | * Резолвер для создания провайдеров отвечающих за исполнение функций, проверку условий, выполнение валидаторов и т.д. |
||
82 | * |
||
83 | * @var string |
||
84 | */ |
||
85 | protected $defaultTypeResolverClass = TypeResolver::class; |
||
86 | |||
87 | /** |
||
88 | * |
||
89 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
90 | * @throws \OldTown\Log\Exception\InvalidArgumentException |
||
91 | * @throws \OldTown\Log\Exception\DomainException |
||
92 | * |
||
93 | */ |
||
94 | public function __construct() |
||
98 | |||
99 | /** |
||
100 | * Инициализация workflow. Workflow нужно иницаилизровать прежде, чем выполнять какие либо действия. |
||
101 | * Workflow может быть инициализированно только один раз |
||
102 | * |
||
103 | * @param string $workflowName Имя workflow |
||
104 | * @param integer $initialAction Имя первого шага, с которого начинается workflow |
||
105 | * @param TransientVarsInterface $inputs Данные введеные пользователем |
||
106 | 19 | * @return integer |
|
107 | * @throws \OldTown\Workflow\Exception\InvalidRoleException |
||
108 | 19 | * @throws \OldTown\Workflow\Exception\InvalidInputException |
|
109 | 19 | * @throws \OldTown\Workflow\Exception\WorkflowException |
|
110 | 19 | * @throws \OldTown\Workflow\Exception\InvalidEntryStateException |
|
111 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
112 | * @throws \OldTown\Workflow\Exception\FactoryException |
||
113 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
114 | * @throws \OldTown\Workflow\Exception\StoreException |
||
115 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
116 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
117 | 19 | * |
|
118 | */ |
||
119 | 19 | public function initialize($workflowName, $initialAction, TransientVarsInterface $inputs = null) |
|
163 | 19 | ||
164 | 19 | /** |
|
165 | 19 | * @param WorkflowEntryInterface $entry |
|
166 | * @param TransientVarsInterface $transientVars |
||
167 | * @param array|Traversable|RegisterDescriptor[]|SplObjectStorage $registersStorage |
||
168 | * @param integer $actionId |
||
169 | * @param array|Traversable $currentSteps |
||
170 | * @param PropertySetInterface $ps |
||
171 | * |
||
172 | 19 | * |
|
173 | * @return TransientVarsInterface |
||
174 | 1 | * |
|
175 | 19 | * @throws \OldTown\Workflow\Exception\WorkflowException |
|
176 | 19 | * @throws \OldTown\Workflow\Exception\FactoryException |
|
177 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
178 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
179 | 19 | * @throws \OldTown\Workflow\Exception\StoreException |
|
180 | */ |
||
181 | protected function populateTransientMap(WorkflowEntryInterface $entry, TransientVarsInterface $transientVars, $registersStorage, $actionId = null, $currentSteps, PropertySetInterface $ps) |
||
247 | |||
248 | /** |
||
249 | * Переход между двумя статусами |
||
250 | * |
||
251 | * @param WorkflowEntryInterface $entry |
||
252 | * @param SplObjectStorage|StepInterface[] $currentSteps |
||
253 | * @param WorkflowStoreInterface $store |
||
254 | * @param WorkflowDescriptor $wf |
||
255 | * @param ActionDescriptor $action |
||
256 | 2 | * @param TransientVarsInterface $transientVars |
|
257 | 2 | * @param TransientVarsInterface $inputs |
|
258 | * @param PropertySetInterface $ps |
||
259 | * |
||
260 | * @return boolean |
||
261 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
262 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
263 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
264 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
265 | * @throws \OldTown\Workflow\Exception\StoreException |
||
266 | * @throws \OldTown\Workflow\Exception\InvalidEntryStateException |
||
267 | * @throws \OldTown\Workflow\Exception\InvalidInputException |
||
268 | * @throws \OldTown\Workflow\Exception\FactoryException |
||
269 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
270 | */ |
||
271 | protected function transitionWorkflow(WorkflowEntryInterface $entry, SplObjectStorage $currentSteps, WorkflowStoreInterface $store, WorkflowDescriptor $wf, ActionDescriptor $action, TransientVarsInterface $transientVars, TransientVarsInterface $inputs, PropertySetInterface $ps) |
||
498 | |||
499 | |||
500 | /** |
||
501 | * @param $id |
||
502 | * @param TransientVarsInterface $inputs |
||
503 | * |
||
504 | * @return array |
||
505 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
506 | */ |
||
507 | protected function getAvailableAutoActions($id, TransientVarsInterface $inputs) |
||
573 | |||
574 | |||
575 | /** |
||
576 | * @param WorkflowDescriptor $wf |
||
577 | * @param StepInterface $step |
||
578 | * @param TransientVarsInterface $transientVars |
||
579 | 19 | * @param PropertySetInterface $ps |
|
580 | * |
||
581 | * @return array |
||
582 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
583 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
584 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
585 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
586 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
587 | */ |
||
588 | 19 | protected function getAvailableAutoActionsForStep(WorkflowDescriptor $wf, StepInterface $step, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
|
615 | 16 | ||
616 | 16 | /** |
|
617 | * @param ActionDescriptor $action |
||
618 | 16 | * @param $id |
|
619 | * @param array|Traversable $currentSteps |
||
620 | * @param $state |
||
621 | * |
||
622 | 16 | * @return void |
|
623 | 16 | * |
|
624 | * @throws \OldTown\Workflow\Exception\StoreException |
||
625 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
626 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
627 | */ |
||
628 | protected function completeEntry(ActionDescriptor $action = null, $id, $currentSteps, $state) |
||
645 | 16 | /** |
|
646 | 16 | * @param ResultDescriptor $theResult |
|
647 | 16 | * @param WorkflowEntryInterface $entry |
|
648 | 16 | * @param WorkflowStoreInterface $store |
|
649 | 16 | * @param integer $actionId |
|
650 | 16 | * @param StepInterface $currentStep |
|
651 | * @param array $previousIds |
||
652 | * @param TransientVarsInterface $transientVars |
||
653 | * @param PropertySetInterface $ps |
||
654 | * |
||
655 | * @return StepInterface |
||
656 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
657 | * @throws \OldTown\Workflow\Exception\StoreException |
||
658 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
659 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
660 | */ |
||
661 | protected function createNewCurrentStep( |
||
768 | |||
769 | /** |
||
770 | 19 | * Создает хранилище переменных |
|
771 | 19 | * |
|
772 | 19 | * @param $class |
|
773 | 19 | * |
|
774 | * @return TransientVarsInterface |
||
775 | 19 | */ |
|
776 | protected function transientVarsFactory($class = BaseTransientVars::class) |
||
781 | |||
782 | /** |
||
783 | * |
||
784 | * |
||
785 | 19 | * Perform an action on the specified workflow instance. |
|
786 | * @param integer $id The workflow instance id. |
||
787 | 19 | * @param integer $actionId The action id to perform (action id's are listed in the workflow descriptor). |
|
788 | * @param TransientVarsInterface $inputs The inputs to the workflow instance. |
||
789 | * @throws \OldTown\Workflow\Exception\InvalidInputException if a validator is specified and an input is invalid. |
||
790 | * @throws WorkflowException if the action is invalid for the specified workflow |
||
791 | * instance's current state. |
||
792 | * |
||
793 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
794 | * @throws \OldTown\Workflow\Exception\StoreException |
||
795 | * @throws \OldTown\Workflow\Exception\FactoryException |
||
796 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
797 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
798 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
799 | * @throws \OldTown\Workflow\Exception\InvalidEntryStateException |
||
800 | 19 | * @throws \OldTown\Workflow\Exception\WorkflowException |
|
801 | */ |
||
802 | 19 | public function doAction($id, $actionId, TransientVarsInterface $inputs = null) |
|
874 | |||
875 | /** |
||
876 | * @param ActionDescriptor $action |
||
877 | * @param $id |
||
878 | * |
||
879 | * @return void |
||
880 | * |
||
881 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
882 | * @throws \OldTown\Workflow\Exception\StoreException |
||
883 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
884 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
885 | * |
||
886 | */ |
||
887 | protected function checkImplicitFinish(ActionDescriptor $action, $id) |
||
914 | |||
915 | /** |
||
916 | * |
||
917 | * Check if the state of the specified workflow instance can be changed to the new specified one. |
||
918 | * @param integer $id The workflow instance id. |
||
919 | * @param integer $newState The new state id. |
||
920 | * @return boolean true if the state of the workflow can be modified, false otherwise. |
||
921 | * @throws \OldTown\Workflow\Exception\StoreException |
||
922 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
923 | * |
||
924 | */ |
||
925 | public function canModifyEntryState($id, $newState) |
||
983 | |||
984 | |||
985 | /** |
||
986 | * |
||
987 | * Возвращает коллекцию объектов описывающие состояние для текущего экземпляра workflow |
||
988 | * |
||
989 | * @param integer $id id экземпляра workflow |
||
990 | * @return SplObjectStorage|StepInterface[] |
||
991 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
992 | */ |
||
993 | View Code Duplication | public function getCurrentSteps($id) |
|
1010 | |||
1011 | /** |
||
1012 | * |
||
1013 | * |
||
1014 | * Modify the state of the specified workflow instance. |
||
1015 | * @param integer $id The workflow instance id. |
||
1016 | * @param integer $newState the new state to change the workflow instance to. |
||
1017 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1018 | * @throws \OldTown\Workflow\Exception\StoreException |
||
1019 | * @throws \OldTown\Workflow\Exception\InvalidEntryStateException |
||
1020 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1021 | */ |
||
1022 | public function changeEntryState($id, $newState) |
||
1060 | |||
1061 | |||
1062 | /** |
||
1063 | * @param FunctionDescriptor $function |
||
1064 | * @param TransientVarsInterface $transientVars |
||
1065 | * @param PropertySetInterface $ps |
||
1066 | * |
||
1067 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1068 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1069 | */ |
||
1070 | protected function executeFunction(FunctionDescriptor $function, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
||
1099 | |||
1100 | |||
1101 | /** |
||
1102 | * @param WorkflowEntryInterface $entry |
||
1103 | * @param $validatorsStorage |
||
1104 | * @param TransientVarsInterface $transientVars |
||
1105 | * @param PropertySetInterface $ps |
||
1106 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1107 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1108 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1109 | * @throws \OldTown\Workflow\Exception\InvalidInputException |
||
1110 | */ |
||
1111 | protected function verifyInputs(WorkflowEntryInterface $entry, $validatorsStorage, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
||
1166 | |||
1167 | |||
1168 | /** |
||
1169 | * Возвращает текущий шаг |
||
1170 | * |
||
1171 | * @param WorkflowDescriptor $wfDesc |
||
1172 | * @param integer $actionId |
||
1173 | * @param StepInterface[]|SplObjectStorage $currentSteps |
||
1174 | * @param TransientVarsInterface $transientVars |
||
1175 | * @param PropertySetInterface $ps |
||
1176 | * |
||
1177 | * @return StepInterface |
||
1178 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1179 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1180 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1181 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1182 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
1183 | */ |
||
1184 | protected function getCurrentStep(WorkflowDescriptor $wfDesc, $actionId, SplObjectStorage $currentSteps, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
||
1203 | |||
1204 | /** |
||
1205 | * @param ActionDescriptor|null $action |
||
1206 | * @param TransientVarsInterface $transientVars |
||
1207 | * @param PropertySetInterface $ps |
||
1208 | * @param $stepId |
||
1209 | * |
||
1210 | * @return boolean |
||
1211 | * |
||
1212 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1213 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1214 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1215 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
1216 | 19 | */ |
|
1217 | protected function isActionAvailable(ActionDescriptor $action = null, TransientVarsInterface $transientVars, PropertySetInterface $ps, $stepId) |
||
1250 | |||
1251 | /** |
||
1252 | * По дейсвтию получаем дексрипторв workflow |
||
1253 | * |
||
1254 | * @param ActionDescriptor $action |
||
1255 | * @return WorkflowDescriptor |
||
1256 | * |
||
1257 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1258 | */ |
||
1259 | private function getWorkflowDescriptorForAction(ActionDescriptor $action) |
||
1276 | |||
1277 | |||
1278 | /** |
||
1279 | * Проверяет имеет ли пользователь достаточно прав, что бы иниициировать вызываемый процесс |
||
1280 | * |
||
1281 | * @param string $workflowName имя workflow |
||
1282 | * @param integer $initialAction id начального состояния |
||
1283 | * @param TransientVarsInterface $inputs |
||
1284 | * |
||
1285 | * @return bool |
||
1286 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1287 | * @throws \OldTown\Workflow\Exception\FactoryException |
||
1288 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1289 | * @throws \OldTown\Workflow\Exception\StoreException |
||
1290 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1291 | */ |
||
1292 | public function canInitialize($workflowName, $initialAction, TransientVarsInterface $inputs = null) |
||
1329 | |||
1330 | |||
1331 | /** |
||
1332 | * Проверяет имеет ли пользователь достаточно прав, что бы иниициировать вызываемый процесс |
||
1333 | * |
||
1334 | * @param string $workflowName имя workflow |
||
1335 | * @param integer $initialAction id начального состояния |
||
1336 | * @param TransientVarsInterface $transientVars |
||
1337 | * |
||
1338 | * @param PropertySetInterface $ps |
||
1339 | * |
||
1340 | * @return bool |
||
1341 | * |
||
1342 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1343 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1344 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
1345 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1346 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1347 | */ |
||
1348 | protected function canInitializeInternal($workflowName, $initialAction, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
||
1374 | |||
1375 | /** |
||
1376 | * Возвращает резолвер |
||
1377 | * |
||
1378 | * @return TypeResolverInterface |
||
1379 | */ |
||
1380 | public function getResolver() |
||
1393 | |||
1394 | /** |
||
1395 | * Возвращает хранилище состояния workflow |
||
1396 | * |
||
1397 | * @return WorkflowStoreInterface |
||
1398 | * @throws \OldTown\Workflow\Exception\StoreException |
||
1399 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1400 | */ |
||
1401 | protected function getPersistence() |
||
1405 | |||
1406 | /** |
||
1407 | * Получить конфигурацию workflow. Метод также проверяет была ли иницилазированн конфигурация, если нет, то |
||
1408 | * инициализирует ее. |
||
1409 | * |
||
1410 | * Если конфигурация не была установленна, то возвращает конфигурацию по умолчанию |
||
1411 | * |
||
1412 | * @return ConfigurationInterface|DefaultConfiguration Конфигурация которая была установленна |
||
1413 | * |
||
1414 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1415 | */ |
||
1416 | public function getConfiguration() |
||
1432 | |||
1433 | /** |
||
1434 | * @return LoggerInterface |
||
1435 | */ |
||
1436 | public function getLog() |
||
1440 | |||
1441 | /** |
||
1442 | * @param LoggerInterface $log |
||
1443 | * |
||
1444 | * @return $this |
||
1445 | * @throws InternalWorkflowException |
||
1446 | */ |
||
1447 | public function setLog($log) |
||
1461 | |||
1462 | |||
1463 | /** |
||
1464 | * Get the workflow descriptor for the specified workflow name. |
||
1465 | * |
||
1466 | * @param string $workflowName The workflow name. |
||
1467 | * @return WorkflowDescriptor |
||
1468 | * @throws InternalWorkflowException |
||
1469 | */ |
||
1470 | public function getWorkflowDescriptor($workflowName) |
||
1480 | |||
1481 | |||
1482 | /** |
||
1483 | * Executes a special trigger-function using the context of the given workflow instance id. |
||
1484 | * Note that this method is exposed for Quartz trigger jobs, user code should never call it. |
||
1485 | * @param integer $id The workflow instance id |
||
1486 | * @param integer $triggerId The id of the special trigger-function |
||
1487 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1488 | * @throws \OldTown\Workflow\Exception\StoreException |
||
1489 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1490 | * @throws \OldTown\Workflow\Exception\FactoryException |
||
1491 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1492 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1493 | */ |
||
1494 | public function executeTriggerFunction($id, $triggerId) |
||
1518 | |||
1519 | /** |
||
1520 | * @param $id |
||
1521 | * @param $inputs |
||
1522 | * |
||
1523 | * @return array |
||
1524 | * @throws \OldTown\Workflow\Exception\StoreException |
||
1525 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1526 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1527 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1528 | * @throws \OldTown\Workflow\Exception\FactoryException |
||
1529 | */ |
||
1530 | public function getAvailableActions($id, TransientVarsInterface $inputs = null) |
||
1603 | |||
1604 | /** |
||
1605 | * @param WorkflowDescriptor $wf |
||
1606 | * @param StepInterface $step |
||
1607 | * @param TransientVarsInterface $transientVars |
||
1608 | * @param PropertySetInterface $ps |
||
1609 | * |
||
1610 | * @return array |
||
1611 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1612 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1613 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1614 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1615 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
1616 | */ |
||
1617 | protected function getAvailableActionsForStep(WorkflowDescriptor $wf, StepInterface $step, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
||
1659 | |||
1660 | /** |
||
1661 | * @param ConfigurationInterface $configuration |
||
1662 | * |
||
1663 | * @return $this |
||
1664 | */ |
||
1665 | public function setConfiguration(ConfigurationInterface $configuration) |
||
1671 | |||
1672 | /** |
||
1673 | * Возвращает состояние для текущего экземпляра workflow |
||
1674 | * |
||
1675 | * @param integer $id id экземпляра workflow |
||
1676 | * @return integer id текущего состояния |
||
1677 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1678 | */ |
||
1679 | public function getEntryState($id) |
||
1695 | |||
1696 | /** |
||
1697 | * Returns a list of all steps that are completed for the given workflow instance id. |
||
1698 | * |
||
1699 | * @param integer $id The workflow instance id. |
||
1700 | * @return StepInterface[] a List of Steps |
||
1701 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1702 | */ |
||
1703 | View Code Duplication | public function getHistorySteps($id) |
|
1719 | |||
1720 | /** |
||
1721 | * Настройки хранилища |
||
1722 | * |
||
1723 | * @return array |
||
1724 | * |
||
1725 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1726 | */ |
||
1727 | public function getPersistenceProperties() |
||
1731 | |||
1732 | |||
1733 | /** |
||
1734 | * Get the PropertySet for the specified workflow instance id. |
||
1735 | * @param integer $id The workflow instance id. |
||
1736 | * @return PropertySetInterface |
||
1737 | * |
||
1738 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1739 | */ |
||
1740 | View Code Duplication | public function getPropertySet($id) |
|
1756 | |||
1757 | /** |
||
1758 | * @return \String[] |
||
1759 | * |
||
1760 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1761 | */ |
||
1762 | public function getWorkflowNames() |
||
1773 | |||
1774 | /** |
||
1775 | * @param TypeResolverInterface $typeResolver |
||
1776 | * |
||
1777 | * @return $this |
||
1778 | */ |
||
1779 | public function setTypeResolver(TypeResolverInterface $typeResolver) |
||
1785 | |||
1786 | |||
1787 | /** |
||
1788 | * Get a collection (Strings) of currently defined permissions for the specified workflow instance. |
||
1789 | * @param integer $id id the workflow instance id. |
||
1790 | * @param TransientVarsInterface $inputs inputs The inputs to the workflow instance. |
||
1791 | * @return array A List of permissions specified currently (a permission is a string name). |
||
1792 | * |
||
1793 | */ |
||
1794 | public function getSecurityPermissions($id, TransientVarsInterface $inputs = null) |
||
1849 | |||
1850 | |||
1851 | /** |
||
1852 | * Get the name of the specified workflow instance. |
||
1853 | * |
||
1854 | * @param integer $id the workflow instance id. |
||
1855 | * @return string |
||
1856 | * |
||
1857 | * @throws \OldTown\Workflow\Exception\StoreException |
||
1858 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1859 | */ |
||
1860 | public function getWorkflowName($id) |
||
1879 | |||
1880 | /** |
||
1881 | * Удаляет workflow |
||
1882 | * |
||
1883 | * @param string $workflowName |
||
1884 | * |
||
1885 | * @return bool |
||
1886 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1887 | */ |
||
1888 | public function removeWorkflowDescriptor($workflowName) |
||
1892 | |||
1893 | /** |
||
1894 | * @param $workflowName |
||
1895 | * @param WorkflowDescriptor $descriptor |
||
1896 | * @param $replace |
||
1897 | * |
||
1898 | * @return bool |
||
1899 | * |
||
1900 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1901 | */ |
||
1902 | public function saveWorkflowDescriptor($workflowName, WorkflowDescriptor $descriptor, $replace) |
||
1908 | |||
1909 | |||
1910 | /** |
||
1911 | * Query the workflow store for matching instances |
||
1912 | * |
||
1913 | * @param WorkflowExpressionQuery $query |
||
1914 | * |
||
1915 | * @return array |
||
1916 | * |
||
1917 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1918 | * @throws \OldTown\Workflow\Exception\StoreException |
||
1919 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1920 | |||
1921 | */ |
||
1922 | public function query(WorkflowExpressionQuery $query) |
||
1926 | |||
1927 | /** |
||
1928 | * @return string |
||
1929 | */ |
||
1930 | public function getDefaultTypeResolverClass() |
||
1934 | |||
1935 | /** |
||
1936 | * @param string $defaultTypeResolverClass |
||
1937 | * |
||
1938 | * @return $this |
||
1939 | */ |
||
1940 | public function setDefaultTypeResolverClass($defaultTypeResolverClass) |
||
1946 | |||
1947 | |||
1948 | /** |
||
1949 | * @param ConditionsDescriptor $descriptor |
||
1950 | * @param TransientVarsInterface $transientVars |
||
1951 | * @param PropertySetInterface $ps |
||
1952 | * @param $currentStepId |
||
1953 | * |
||
1954 | * @return bool |
||
1955 | * |
||
1956 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1957 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1958 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1959 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
1960 | */ |
||
1961 | protected function passesConditionsByDescriptor(ConditionsDescriptor $descriptor = null, TransientVarsInterface $transientVars, PropertySetInterface $ps, $currentStepId) |
||
1973 | |||
1974 | /** |
||
1975 | * @param string $conditionType |
||
1976 | * @param SplObjectStorage $conditions |
||
1977 | * @param TransientVarsInterface $transientVars |
||
1978 | * @param PropertySetInterface $ps |
||
1979 | * @param integer $currentStepId |
||
1980 | * |
||
1981 | * @return bool |
||
1982 | * @throws \OldTown\Workflow\Exception\InvalidArgumentException |
||
1983 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
1984 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
1985 | * @throws \OldTown\Workflow\Exception\InvalidActionException |
||
1986 | */ |
||
1987 | protected function passesConditionsWithType($conditionType, SplObjectStorage $conditions = null, TransientVarsInterface $transientVars, PropertySetInterface $ps, $currentStepId) |
||
2020 | |||
2021 | /** |
||
2022 | * @param ConditionDescriptor $conditionDesc |
||
2023 | * @param TransientVarsInterface $transientVars |
||
2024 | * @param PropertySetInterface $ps |
||
2025 | * @param integer $currentStepId |
||
2026 | * |
||
2027 | * @return boolean |
||
2028 | * |
||
2029 | * @throws \OldTown\Workflow\Exception\InternalWorkflowException |
||
2030 | * @throws \OldTown\Workflow\Exception\WorkflowException |
||
2031 | */ |
||
2032 | protected function passesCondition(ConditionDescriptor $conditionDesc, TransientVarsInterface $transientVars, PropertySetInterface $ps, $currentStepId) |
||
2080 | } |
||
2081 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: