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 |
||
51 | abstract class AbstractWorkflow implements WorkflowInterface |
||
52 | { |
||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | const CURRENT_STEPS = 'currentSteps'; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | */ |
||
61 | const HISTORY_STEPS = 'historySteps'; |
||
62 | |||
63 | /** |
||
64 | * @var WorkflowContextInterface |
||
65 | */ |
||
66 | protected $context; |
||
67 | |||
68 | /** |
||
69 | * @var ConfigurationInterface |
||
70 | */ |
||
71 | protected $configuration; |
||
72 | |||
73 | /** |
||
74 | * |
||
75 | * @var array |
||
76 | */ |
||
77 | protected $stateCache = []; |
||
78 | |||
79 | /** |
||
80 | * @var TypeResolverInterface |
||
81 | */ |
||
82 | protected $typeResolver; |
||
83 | |||
84 | /** |
||
85 | * Логер |
||
86 | * |
||
87 | * @var LoggerInterface |
||
88 | */ |
||
89 | protected $log; |
||
90 | |||
91 | /** |
||
92 | * Резолвер для создания провайдеров отвечающих за исполнение функций, проверку условий, выполнение валидаторов и т.д. |
||
93 | * |
||
94 | * @var string |
||
95 | */ |
||
96 | protected $defaultTypeResolverClass = TypeResolver::class; |
||
97 | |||
98 | /** |
||
99 | * AbstractWorkflow constructor. |
||
100 | * |
||
101 | * @throws InternalWorkflowException |
||
102 | */ |
||
103 | 19 | public function __construct() |
|
107 | |||
108 | /** |
||
109 | * Инициализация системы логирования |
||
110 | * |
||
111 | * @throws InternalWorkflowException |
||
112 | */ |
||
113 | 19 | protected function initLoger() |
|
121 | |||
122 | /** |
||
123 | * Инициализация workflow. Workflow нужно иницаилизровать прежде, чем выполнять какие либо действия. |
||
124 | * Workflow может быть инициализированно только один раз |
||
125 | * |
||
126 | * @param string $workflowName Имя workflow |
||
127 | * @param integer $initialAction Имя первого шага, с которого начинается workflow |
||
128 | * @param TransientVarsInterface $inputs Данные введеные пользователем |
||
129 | * |
||
130 | * @return integer |
||
131 | * |
||
132 | * @throws InternalWorkflowException |
||
133 | * @throws InvalidActionException |
||
134 | * @throws InvalidRoleException |
||
135 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
136 | * @throws InvalidArgumentException |
||
137 | * @throws WorkflowException |
||
138 | */ |
||
139 | 19 | public function initialize($workflowName, $initialAction, TransientVarsInterface $inputs = null) |
|
188 | |||
189 | /** |
||
190 | * @param WorkflowEntryInterface $entry |
||
191 | * @param TransientVarsInterface $transientVars |
||
192 | * @param array|Traversable|RegisterDescriptor[]|SplObjectStorage $registersStorage |
||
193 | * @param integer $actionId |
||
194 | * @param array|Traversable $currentSteps |
||
195 | * @param PropertySetInterface $ps |
||
196 | * |
||
197 | * |
||
198 | * @return TransientVarsInterface |
||
199 | * |
||
200 | * @throws InvalidArgumentException |
||
201 | * @throws WorkflowException |
||
202 | * @throws InternalWorkflowException |
||
203 | */ |
||
204 | 19 | protected function populateTransientMap(WorkflowEntryInterface $entry, TransientVarsInterface $transientVars, $registersStorage, $actionId = null, $currentSteps, PropertySetInterface $ps) |
|
259 | |||
260 | /** |
||
261 | * Проверка того что данные могут быть использованы в цикле |
||
262 | * |
||
263 | * @param $data |
||
264 | * |
||
265 | * @throws InvalidArgumentException |
||
266 | */ |
||
267 | 19 | protected function validateIterateData($data) |
|
274 | |||
275 | /** |
||
276 | * Преобразование данных в массив |
||
277 | * |
||
278 | * @param $data |
||
279 | * |
||
280 | * @return array |
||
281 | * |
||
282 | * @throws InvalidArgumentException |
||
283 | */ |
||
284 | 19 | protected function convertDataInArray($data) |
|
300 | |||
301 | |||
302 | /** |
||
303 | * Переход между двумя статусами |
||
304 | * |
||
305 | * @param WorkflowEntryInterface $entry |
||
306 | * @param SplObjectStorage|StepInterface[] $currentSteps |
||
307 | * @param WorkflowStoreInterface $store |
||
308 | * @param WorkflowDescriptor $wf |
||
309 | * @param ActionDescriptor $action |
||
310 | * @param TransientVarsInterface $transientVars |
||
311 | * @param TransientVarsInterface $inputs |
||
312 | * @param PropertySetInterface $ps |
||
313 | * |
||
314 | * @return boolean |
||
315 | * |
||
316 | * @throws InternalWorkflowException |
||
317 | */ |
||
318 | 18 | protected function transitionWorkflow(WorkflowEntryInterface $entry, SplObjectStorage $currentSteps, WorkflowStoreInterface $store, WorkflowDescriptor $wf, ActionDescriptor $action, TransientVarsInterface $transientVars, TransientVarsInterface $inputs, PropertySetInterface $ps) |
|
540 | |||
541 | /** |
||
542 | * Подготавливает данные о шагах используемых в объеденение |
||
543 | * |
||
544 | * @param StepInterface[]|SplObjectStorage $steps |
||
545 | * @param StepInterface $step |
||
546 | * @param WorkflowDescriptor $wf |
||
547 | * @param integer $join |
||
548 | * |
||
549 | * @param array $joinSteps |
||
550 | * |
||
551 | * @return array |
||
552 | * |
||
553 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
554 | */ |
||
555 | protected function buildJoinsSteps($steps, StepInterface $step, WorkflowDescriptor $wf, $join, array $joinSteps = []) |
||
569 | |||
570 | /** |
||
571 | * @param $id |
||
572 | * @param TransientVarsInterface $inputs |
||
573 | * |
||
574 | * @return array |
||
575 | */ |
||
576 | 19 | protected function getAvailableAutoActions($id, TransientVarsInterface $inputs) |
|
577 | { |
||
578 | try { |
||
579 | 16 | $store = $this->getPersistence(); |
|
580 | 16 | $entry = $store->findEntry($id); |
|
581 | |||
582 | 16 | if (null === $entry) { |
|
583 | $errMsg = sprintf( |
||
584 | 'Нет сущности workflow c id %s', |
||
585 | $id |
||
586 | ); |
||
587 | throw new InvalidArgumentException($errMsg); |
||
588 | 19 | } |
|
589 | |||
590 | |||
591 | 16 | if (WorkflowEntryInterface::ACTIVATED !== $entry->getState()) { |
|
592 | $logMsg = sprintf('--> состояние %s', $entry->getState()); |
||
593 | $this->getLog()->debug($logMsg); |
||
594 | return [0]; |
||
595 | } |
||
596 | |||
597 | 16 | $wf = $this->getConfiguration()->getWorkflow($entry->getWorkflowName()); |
|
598 | |||
599 | 16 | $l = []; |
|
600 | 16 | $ps = $store->getPropertySet($id); |
|
601 | 16 | $transientVars = $inputs; |
|
602 | 16 | $currentSteps = $store->findCurrentSteps($id); |
|
603 | |||
604 | 16 | $this->populateTransientMap($entry, $transientVars, $wf->getRegisters(), 0, $currentSteps, $ps); |
|
605 | |||
606 | 16 | $globalActions = $wf->getGlobalActions(); |
|
607 | |||
608 | 16 | $l = $this->buildListIdsAvailableActions($globalActions, $transientVars, $ps, $l); |
|
609 | |||
610 | 16 | View Code Duplication | foreach ($currentSteps as $step) { |
611 | 16 | $availableAutoActionsForStep = $this->getAvailableAutoActionsForStep($wf, $step, $transientVars, $ps); |
|
612 | foreach ($availableAutoActionsForStep as $v) { |
||
613 | $l[] = $v; |
||
614 | } |
||
615 | } |
||
616 | |||
617 | $l = array_unique($l); |
||
618 | |||
619 | return $l; |
||
620 | 16 | } catch (\Exception $e) { |
|
621 | 16 | $errMsg = 'Ошибка при проверке доступных действий'; |
|
622 | 16 | $this->getLog()->error($errMsg, [$e]); |
|
623 | } |
||
624 | |||
625 | 16 | return []; |
|
626 | } |
||
627 | |||
628 | /** |
||
629 | * @param $id |
||
630 | * @param $inputs |
||
631 | * |
||
632 | * @return array |
||
633 | * |
||
634 | */ |
||
635 | public function getAvailableActions($id, TransientVarsInterface $inputs = null) |
||
700 | |||
701 | /** |
||
702 | * Подготавливает список id действий в workflow |
||
703 | * |
||
704 | * @param ActionDescriptor[]|SplObjectStorage $actions |
||
705 | * @param TransientVarsInterface $transientVars |
||
706 | * @param PropertySetInterface $ps |
||
707 | * @param array $storage |
||
708 | * |
||
709 | * @return array |
||
710 | * |
||
711 | * @throws InternalWorkflowException |
||
712 | * @throws WorkflowException |
||
713 | */ |
||
714 | 16 | protected function buildListIdsAvailableActions($actions, TransientVarsInterface $transientVars, PropertySetInterface $ps, array $storage = []) |
|
730 | |||
731 | /** |
||
732 | * @param WorkflowDescriptor $wf |
||
733 | * @param StepInterface $step |
||
734 | * @param TransientVarsInterface $transientVars |
||
735 | * @param PropertySetInterface $ps |
||
736 | * |
||
737 | * @return array |
||
738 | * |
||
739 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
740 | * @throws InternalWorkflowException |
||
741 | * @throws WorkflowException |
||
742 | */ |
||
743 | 16 | protected function getAvailableAutoActionsForStep(WorkflowDescriptor $wf, StepInterface $step, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
|
764 | |||
765 | /** |
||
766 | * @param ActionDescriptor $action |
||
767 | * @param $id |
||
768 | * @param array|Traversable $currentSteps |
||
769 | * @param $state |
||
770 | * |
||
771 | * @return void |
||
772 | * |
||
773 | * @throws InvalidArgumentException |
||
774 | * @throws InternalWorkflowException |
||
775 | */ |
||
776 | protected function completeEntry(ActionDescriptor $action = null, $id, $currentSteps, $state) |
||
790 | /** |
||
791 | * @param ResultDescriptor $theResult |
||
792 | * @param WorkflowEntryInterface $entry |
||
793 | * @param WorkflowStoreInterface $store |
||
794 | * @param integer $actionId |
||
795 | * @param StepInterface $currentStep |
||
796 | * @param array $previousIds |
||
797 | * @param TransientVarsInterface $transientVars |
||
798 | * @param PropertySetInterface $ps |
||
799 | * |
||
800 | * @return StepInterface |
||
801 | * |
||
802 | * @throws InternalWorkflowException |
||
803 | * @throws StoreException |
||
804 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
805 | * @throws WorkflowException |
||
806 | */ |
||
807 | 16 | protected function createNewCurrentStep( |
|
916 | |||
917 | /** |
||
918 | * Создает хранилище переменных |
||
919 | * |
||
920 | * @param $class |
||
921 | * |
||
922 | * @return TransientVarsInterface |
||
923 | */ |
||
924 | protected function transientVarsFactory($class = BaseTransientVars::class) |
||
929 | |||
930 | /** |
||
931 | * |
||
932 | * |
||
933 | * Осуществляет переходл в новое состояние, для заданного процесса workflow |
||
934 | * |
||
935 | * @param integer $entryId id запущенного процесса workflow |
||
936 | * @param integer $actionId id действия, доступного та текущем шаеге процессса workflow |
||
937 | * @param TransientVarsInterface $inputs Входные данные для перехода |
||
938 | * |
||
939 | * @return void |
||
940 | * |
||
941 | * @throws WorkflowException |
||
942 | * @throws InvalidActionException |
||
943 | * @throws InvalidArgumentException |
||
944 | * @throws InternalWorkflowException |
||
945 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
946 | */ |
||
947 | 8 | public function doAction($entryId, $actionId, TransientVarsInterface $inputs = null) |
|
1025 | |||
1026 | /** |
||
1027 | * @param ActionDescriptor $action |
||
1028 | * @param $id |
||
1029 | * |
||
1030 | * @return void |
||
1031 | * |
||
1032 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1033 | * @throws InvalidArgumentException |
||
1034 | * @throws InternalWorkflowException |
||
1035 | */ |
||
1036 | protected function checkImplicitFinish(ActionDescriptor $action, $id) |
||
1063 | |||
1064 | /** |
||
1065 | * |
||
1066 | * Check if the state of the specified workflow instance can be changed to the new specified one. |
||
1067 | * |
||
1068 | * @param integer $id The workflow instance id. |
||
1069 | * @param integer $newState The new state id. |
||
1070 | * |
||
1071 | * @return boolean true if the state of the workflow can be modified, false otherwise. |
||
1072 | * |
||
1073 | * @throws InternalWorkflowException |
||
1074 | */ |
||
1075 | 16 | public function canModifyEntryState($id, $newState) |
|
1135 | |||
1136 | |||
1137 | /** |
||
1138 | * |
||
1139 | * Возвращает коллекцию объектов описывающие состояние для текущего экземпляра workflow |
||
1140 | * |
||
1141 | * @param integer $entryId id экземпляра workflow |
||
1142 | * |
||
1143 | * @return SplObjectStorage|StepInterface[] |
||
1144 | * |
||
1145 | * @throws InternalWorkflowException |
||
1146 | */ |
||
1147 | public function getCurrentSteps($entryId) |
||
1151 | |||
1152 | /** |
||
1153 | * Возвращает информацию о том в какие шаги, были осуществленны переходы, для процесса workflow с заданным id |
||
1154 | * |
||
1155 | * @param integer $entryId уникальный идентификатор процесса workflow |
||
1156 | * |
||
1157 | * @return StepInterface[]|SplObjectStorage список шагов |
||
1158 | * |
||
1159 | * @throws InternalWorkflowException |
||
1160 | */ |
||
1161 | public function getHistorySteps($entryId) |
||
1165 | |||
1166 | /** |
||
1167 | * Получение шагов информации о шагах процесса workflow |
||
1168 | * |
||
1169 | * @param $entryId |
||
1170 | * @param $type |
||
1171 | * |
||
1172 | * @return Spi\StepInterface[]|SplObjectStorage |
||
1173 | * |
||
1174 | * @throws InternalWorkflowException |
||
1175 | */ |
||
1176 | protected function getStepFromStorage($entryId, $type) |
||
1196 | |||
1197 | |||
1198 | |||
1199 | /** |
||
1200 | * |
||
1201 | * |
||
1202 | * Modify the state of the specified workflow instance. |
||
1203 | * @param integer $id The workflow instance id. |
||
1204 | * @param integer $newState the new state to change the workflow instance to. |
||
1205 | * |
||
1206 | * @throws InvalidArgumentException |
||
1207 | * @throws InvalidEntryStateException |
||
1208 | * @throws InternalWorkflowException |
||
1209 | */ |
||
1210 | 16 | public function changeEntryState($id, $newState) |
|
1247 | |||
1248 | |||
1249 | /** |
||
1250 | * @param FunctionDescriptor $function |
||
1251 | * @param TransientVarsInterface $transientVars |
||
1252 | * @param PropertySetInterface $ps |
||
1253 | * |
||
1254 | * @throws WorkflowException |
||
1255 | * @throws InternalWorkflowException |
||
1256 | */ |
||
1257 | 4 | protected function executeFunction(FunctionDescriptor $function, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
|
1282 | |||
1283 | |||
1284 | /** |
||
1285 | * @param $validatorsStorage |
||
1286 | * @param TransientVarsInterface $transientVars |
||
1287 | * @param PropertySetInterface $ps |
||
1288 | * |
||
1289 | * @throws WorkflowException |
||
1290 | * @throws InvalidArgumentException |
||
1291 | * @throws InternalWorkflowException |
||
1292 | * @throws InvalidInputException |
||
1293 | */ |
||
1294 | 15 | protected function verifyInputs($validatorsStorage, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
|
1333 | |||
1334 | |||
1335 | /** |
||
1336 | * Возвращает текущий шаг |
||
1337 | * |
||
1338 | * @param WorkflowDescriptor $wfDesc |
||
1339 | * @param integer $actionId |
||
1340 | * @param StepInterface[]|SplObjectStorage $currentSteps |
||
1341 | * @param TransientVarsInterface $transientVars |
||
1342 | * @param PropertySetInterface $ps |
||
1343 | * |
||
1344 | * @return StepInterface |
||
1345 | * |
||
1346 | * @throws InternalWorkflowException |
||
1347 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1348 | * @throws WorkflowException |
||
1349 | */ |
||
1350 | 18 | protected function getCurrentStep(WorkflowDescriptor $wfDesc, $actionId, SplObjectStorage $currentSteps, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
|
1369 | |||
1370 | /** |
||
1371 | * @param ActionDescriptor|null $action |
||
1372 | * @param TransientVarsInterface $transientVars |
||
1373 | * @param PropertySetInterface $ps |
||
1374 | * @param $stepId |
||
1375 | * |
||
1376 | * @return boolean |
||
1377 | * |
||
1378 | * @throws InternalWorkflowException |
||
1379 | * @throws WorkflowException |
||
1380 | */ |
||
1381 | 8 | protected function isActionAvailable(ActionDescriptor $action = null, TransientVarsInterface $transientVars, PropertySetInterface $ps, $stepId) |
|
1414 | |||
1415 | /** |
||
1416 | * По дейсвтию получаем дексрипторв workflow |
||
1417 | * |
||
1418 | * @param ActionDescriptor $action |
||
1419 | * |
||
1420 | * @return WorkflowDescriptor |
||
1421 | * |
||
1422 | * @throws InternalWorkflowException |
||
1423 | */ |
||
1424 | 8 | private function getWorkflowDescriptorForAction(ActionDescriptor $action) |
|
1441 | |||
1442 | |||
1443 | /** |
||
1444 | * Проверяет имеет ли пользователь достаточно прав, что бы иниициировать вызываемый процесс |
||
1445 | * |
||
1446 | * @param string $workflowName имя workflow |
||
1447 | * @param integer $initialAction id начального состояния |
||
1448 | * @param TransientVarsInterface $inputs |
||
1449 | * |
||
1450 | * @return bool |
||
1451 | * |
||
1452 | * @throws InvalidArgumentException |
||
1453 | * @throws WorkflowException |
||
1454 | * @throws InternalWorkflowException |
||
1455 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1456 | */ |
||
1457 | public function canInitialize($workflowName, $initialAction, TransientVarsInterface $inputs = null) |
||
1500 | |||
1501 | |||
1502 | /** |
||
1503 | * Проверяет имеет ли пользователь достаточно прав, что бы иниициировать вызываемый процесс |
||
1504 | * |
||
1505 | * @param string $workflowName имя workflow |
||
1506 | * @param integer $initialAction id начального состояния |
||
1507 | * @param TransientVarsInterface $transientVars |
||
1508 | * |
||
1509 | * @param PropertySetInterface $ps |
||
1510 | * |
||
1511 | * @return bool |
||
1512 | * |
||
1513 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1514 | * @throws InvalidActionException |
||
1515 | * @throws InternalWorkflowException |
||
1516 | * @throws WorkflowException |
||
1517 | */ |
||
1518 | 19 | protected function canInitializeInternal($workflowName, $initialAction, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
|
1544 | |||
1545 | /** |
||
1546 | * Возвращает резолвер |
||
1547 | * |
||
1548 | * @return TypeResolverInterface |
||
1549 | */ |
||
1550 | 17 | public function getResolver() |
|
1563 | |||
1564 | /** |
||
1565 | * Возвращает хранилище состояния workflow |
||
1566 | * |
||
1567 | * @return WorkflowStoreInterface |
||
1568 | * |
||
1569 | * @throws InternalWorkflowException |
||
1570 | */ |
||
1571 | 19 | protected function getPersistence() |
|
1575 | |||
1576 | /** |
||
1577 | * Получить конфигурацию workflow. Метод также проверяет была ли иницилазированн конфигурация, если нет, то |
||
1578 | * инициализирует ее. |
||
1579 | * |
||
1580 | * Если конфигурация не была установленна, то возвращает конфигурацию по умолчанию |
||
1581 | * |
||
1582 | * @return ConfigurationInterface|DefaultConfiguration Конфигурация которая была установленна |
||
1583 | * |
||
1584 | * @throws InternalWorkflowException |
||
1585 | */ |
||
1586 | 19 | public function getConfiguration() |
|
1602 | |||
1603 | /** |
||
1604 | * @return LoggerInterface |
||
1605 | */ |
||
1606 | 16 | public function getLog() |
|
1610 | |||
1611 | /** |
||
1612 | * @param LoggerInterface $log |
||
1613 | * |
||
1614 | * @return $this |
||
1615 | * |
||
1616 | * @throws InternalWorkflowException |
||
1617 | */ |
||
1618 | public function setLog($log) |
||
1632 | |||
1633 | |||
1634 | /** |
||
1635 | * Get the workflow descriptor for the specified workflow name. |
||
1636 | * |
||
1637 | * @param string $workflowName The workflow name. |
||
1638 | * @return WorkflowDescriptor |
||
1639 | * |
||
1640 | * @throws InternalWorkflowException |
||
1641 | */ |
||
1642 | public function getWorkflowDescriptor($workflowName) |
||
1652 | |||
1653 | |||
1654 | /** |
||
1655 | * Executes a special trigger-function using the context of the given workflow instance id. |
||
1656 | * Note that this method is exposed for Quartz trigger jobs, user code should never call it. |
||
1657 | * |
||
1658 | * @param integer $id The workflow instance id |
||
1659 | * @param integer $triggerId The id of the special trigger-function |
||
1660 | * |
||
1661 | * @throws InvalidArgumentException |
||
1662 | * @throws WorkflowException |
||
1663 | * @throws InternalWorkflowException |
||
1664 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1665 | */ |
||
1666 | public function executeTriggerFunction($id, $triggerId) |
||
1690 | |||
1691 | |||
1692 | /** |
||
1693 | * @param WorkflowDescriptor $wf |
||
1694 | * @param StepInterface $step |
||
1695 | * @param TransientVarsInterface $transientVars |
||
1696 | * @param PropertySetInterface $ps |
||
1697 | * |
||
1698 | * @return array |
||
1699 | * |
||
1700 | * @throws InternalWorkflowException |
||
1701 | * @throws WorkflowException |
||
1702 | * @throws \OldTown\Workflow\Exception\ArgumentNotNumericException |
||
1703 | */ |
||
1704 | protected function getAvailableActionsForStep(WorkflowDescriptor $wf, StepInterface $step, TransientVarsInterface $transientVars, PropertySetInterface $ps) |
||
1746 | |||
1747 | /** |
||
1748 | * @param ConfigurationInterface $configuration |
||
1749 | * |
||
1750 | * @return $this |
||
1751 | */ |
||
1752 | 19 | public function setConfiguration(ConfigurationInterface $configuration) |
|
1758 | |||
1759 | /** |
||
1760 | * Возвращает состояние для текущего экземпляра workflow |
||
1761 | * |
||
1762 | * @param integer $id id экземпляра workflow |
||
1763 | * @return integer id текущего состояния |
||
1764 | * |
||
1765 | * @throws InternalWorkflowException |
||
1766 | */ |
||
1767 | public function getEntryState($id) |
||
1783 | |||
1784 | |||
1785 | /** |
||
1786 | * Настройки хранилища |
||
1787 | * |
||
1788 | * @return array |
||
1789 | * |
||
1790 | * @throws InternalWorkflowException |
||
1791 | */ |
||
1792 | public function getPersistenceProperties() |
||
1796 | |||
1797 | |||
1798 | /** |
||
1799 | * Get the PropertySet for the specified workflow instance id. |
||
1800 | * @param integer $id The workflow instance id. |
||
1801 | * |
||
1802 | * @return PropertySetInterface |
||
1803 | * @throws InternalWorkflowException |
||
1804 | */ |
||
1805 | public function getPropertySet($id) |
||
1821 | |||
1822 | /** |
||
1823 | * @return string[] |
||
1824 | * |
||
1825 | * @throws InternalWorkflowException |
||
1826 | */ |
||
1827 | public function getWorkflowNames() |
||
1838 | |||
1839 | /** |
||
1840 | * @param TypeResolverInterface $typeResolver |
||
1841 | * |
||
1842 | * @return $this |
||
1843 | */ |
||
1844 | public function setTypeResolver(TypeResolverInterface $typeResolver) |
||
1850 | |||
1851 | |||
1852 | /** |
||
1853 | * Get a collection (Strings) of currently defined permissions for the specified workflow instance. |
||
1854 | * @param integer $id id the workflow instance id. |
||
1855 | * @param TransientVarsInterface $inputs inputs The inputs to the workflow instance. |
||
1856 | * |
||
1857 | * @return array A List of permissions specified currently (a permission is a string name). |
||
1858 | * |
||
1859 | */ |
||
1860 | public function getSecurityPermissions($id, TransientVarsInterface $inputs = null) |
||
1919 | |||
1920 | |||
1921 | /** |
||
1922 | * Get the name of the specified workflow instance. |
||
1923 | * |
||
1924 | * @param integer $id the workflow instance id. |
||
1925 | * |
||
1926 | * @return string |
||
1927 | * |
||
1928 | * @throws InternalWorkflowException |
||
1929 | */ |
||
1930 | public function getWorkflowName($id) |
||
1949 | |||
1950 | /** |
||
1951 | * Удаляет workflow |
||
1952 | * |
||
1953 | * @param string $workflowName |
||
1954 | * |
||
1955 | * @return bool |
||
1956 | * |
||
1957 | * @throws InternalWorkflowException |
||
1958 | */ |
||
1959 | public function removeWorkflowDescriptor($workflowName) |
||
1963 | |||
1964 | /** |
||
1965 | * @param $workflowName |
||
1966 | * @param WorkflowDescriptor $descriptor |
||
1967 | * @param $replace |
||
1968 | * |
||
1969 | * @return bool |
||
1970 | * |
||
1971 | * @throws InternalWorkflowException |
||
1972 | */ |
||
1973 | public function saveWorkflowDescriptor($workflowName, WorkflowDescriptor $descriptor, $replace) |
||
1979 | |||
1980 | |||
1981 | /** |
||
1982 | * Query the workflow store for matching instances |
||
1983 | * |
||
1984 | * @param WorkflowExpressionQuery $query |
||
1985 | * |
||
1986 | * @return array |
||
1987 | * |
||
1988 | * @throws InternalWorkflowException |
||
1989 | */ |
||
1990 | public function query(WorkflowExpressionQuery $query) |
||
1994 | |||
1995 | /** |
||
1996 | * @return string |
||
1997 | */ |
||
1998 | 17 | public function getDefaultTypeResolverClass() |
|
2002 | |||
2003 | /** |
||
2004 | * @param string $defaultTypeResolverClass |
||
2005 | * |
||
2006 | * @return $this |
||
2007 | */ |
||
2008 | public function setDefaultTypeResolverClass($defaultTypeResolverClass) |
||
2014 | |||
2015 | |||
2016 | /** |
||
2017 | * @param ConditionsDescriptor $descriptor |
||
2018 | * @param TransientVarsInterface $transientVars |
||
2019 | * @param PropertySetInterface $ps |
||
2020 | * @param $currentStepId |
||
2021 | * |
||
2022 | * @return bool |
||
2023 | * |
||
2024 | * @throws InternalWorkflowException |
||
2025 | * @throws WorkflowException |
||
2026 | */ |
||
2027 | 19 | protected function passesConditionsByDescriptor(ConditionsDescriptor $descriptor = null, TransientVarsInterface $transientVars, PropertySetInterface $ps, $currentStepId) |
|
2043 | |||
2044 | /** |
||
2045 | * @param string $conditionType |
||
2046 | * @param SplObjectStorage $conditions |
||
2047 | * @param TransientVarsInterface $transientVars |
||
2048 | * @param PropertySetInterface $ps |
||
2049 | * @param integer $currentStepId |
||
2050 | * |
||
2051 | * @return bool |
||
2052 | * |
||
2053 | * @throws InternalWorkflowException |
||
2054 | * @throws InternalWorkflowException |
||
2055 | * @throws WorkflowException |
||
2056 | * |
||
2057 | */ |
||
2058 | 13 | protected function passesConditionsWithType($conditionType, SplObjectStorage $conditions = null, TransientVarsInterface $transientVars, PropertySetInterface $ps, $currentStepId) |
|
2100 | |||
2101 | /** |
||
2102 | * @param ConditionDescriptor $conditionDesc |
||
2103 | * @param TransientVarsInterface $transientVars |
||
2104 | * @param PropertySetInterface $ps |
||
2105 | * @param integer $currentStepId |
||
2106 | * |
||
2107 | * @return boolean |
||
2108 | * |
||
2109 | * @throws WorkflowException |
||
2110 | * @throws InternalWorkflowException |
||
2111 | */ |
||
2112 | 12 | protected function passesCondition(ConditionDescriptor $conditionDesc, TransientVarsInterface $transientVars, PropertySetInterface $ps, $currentStepId) |
|
2156 | |||
2157 | /** |
||
2158 | * Подготавливает аргументы. |
||
2159 | * |
||
2160 | * @param array $argsOriginal |
||
2161 | * |
||
2162 | * @param TransientVarsInterface $transientVars |
||
2163 | * @param PropertySetInterface $ps |
||
2164 | * |
||
2165 | * @return array |
||
2166 | * |
||
2167 | * @throws InternalWorkflowException |
||
2168 | */ |
||
2169 | 17 | protected function prepareArgs(array $argsOriginal = [], TransientVarsInterface $transientVars, PropertySetInterface $ps) |
|
2179 | } |
||
2180 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.