Bitrix-D7 22.6
 
Загрузка...
Поиск...
Не найдено
template.php
1<?php
3
6use Bitrix\Bizproc\WorkflowTemplateTable;
14
15Loc::loadMessages(__FILE__);
16
22{
23 protected static $parallelActivityType = 'ParallelActivity';
24 protected static $sequenceActivityType = 'SequenceActivity';
26 protected static $delayActivityType = 'DelayActivity';
27 protected static $robotDelayActivityType = 'RobotDelayActivity';
28 protected static $conditionActivityType = 'IfElseActivity';
29 protected static $availableActivities = [];
30 protected static $availableActivityClasses = [];
31
32 protected $template;
33 protected $autoExecuteType = \CBPDocumentEventType::Automation;
35 protected $robots;
37 protected $isConverted = false;
38
47 public function __construct(array $documentType, $documentStatus = null)
48 {
49 $this->template = array(
50 'ID' => 0,
51 'MODULE_ID' => $documentType[0],
52 'ENTITY' => $documentType[1],
53 'DOCUMENT_TYPE' => $documentType[2],
54 'DOCUMENT_STATUS' => $documentStatus,
55 'AUTO_EXECUTE' => $this->autoExecuteType,
56 'TEMPLATE' => [],
57 'PARAMETERS' => [],
58 'CONSTANTS' => [],
59 'VARIABLES' => [],
60 );
61
62 if ($documentStatus)
63 {
64 $row = WorkflowTemplateTable::getList([
65 'filter' => [
66 '=MODULE_ID' => $documentType[0],
67 '=ENTITY' => $documentType[1],
68 '=DOCUMENT_TYPE' => $documentType[2],
69 '=DOCUMENT_STATUS' => $documentStatus,
70 //'=AUTO_EXECUTE' => $this->autoExecuteType
71 ],
72 ])->fetch();
73 if ($row)
74 {
75 $this->template = $row;
76 $this->autoExecuteType = (int) $this->template['AUTO_EXECUTE'];
77 }
78 }
79 }
80
81 public static function createByTpl(Tpl $tpl)
82 {
83 $instance = new static($tpl->getDocumentComplexType());
84 $instance->template = $tpl->collectValues();
85 $instance->autoExecuteType = (int) $instance->template['AUTO_EXECUTE'];
86
87 return $instance;
88 }
89
90 public function deleteRobots(array $robots, int $userId): Result
91 {
92 $isSameRobot = function ($lhsRobot, $rhsRobot) {
93 return strcmp($lhsRobot->getName(), $rhsRobot->getName());
94 };
95
96 $remainingRobots = array_udiff($this->getRobots(), $robots, $isSameRobot);
97
98 return $this->save($remainingRobots, $userId);
99 }
100
101 public function getDocumentStatus()
102 {
103 return isset($this->template['DOCUMENT_STATUS']) ? $this->template['DOCUMENT_STATUS'] : null;
104 }
105
106 public function setDocumentStatus($status)
107 {
108 $this->template['DOCUMENT_STATUS'] = (string) $status;
109 return $this;
110 }
111
112 public function setName(string $name)
113 {
114 $this->template['NAME'] = $name;
115 return $this;
116 }
117
119 {
121 }
122
124 {
125 if (\CBPDocumentEventType::Out($autoExecuteType) === '')
126 {
127 throw new ArgumentException('Incorrect DocumentEventType');
128 }
129
130 $this->autoExecuteType = $autoExecuteType;
131 }
132
133 public function getId()
134 {
135 return isset($this->template['ID']) ? (int)$this->template['ID'] : 0;
136 }
137
138 public function getParameters(): array
139 {
140 return $this->template['PARAMETERS'] ?? [];
141 }
142
143 public function getRobotSettingsDialog(array $robot, $request = null)
144 {
145 if (isset($robot['Properties']) && is_array($robot['Properties']))
146 {
147 $robot['Properties'] = Automation\Helper::convertProperties($robot['Properties'], $this->getDocumentType());
148 }
149
150 unset($robot['Delay'], $robot['Condition']);
151
152 $copy = clone $this;
153 $copy->setRobots([$robot]);
154
155 return \CBPActivity::callStaticMethod(
156 $robot['Type'],
157 "GetPropertiesDialog",
158 array(
159 $this->getDocumentType(), //documentType
160 $robot['Name'] ?? null, //activityName
161 $copy->template['TEMPLATE'], //arWorkflowTemplate
162 [], //arWorkflowParameters
163 [], //arWorkflowVariables
164 $request, //arCurrentValues = null
165 'bizproc_automation_robot_dialog', //formName = ""
166 null, //popupWindow = null
167 SITE_ID //siteId = ''
168 )
169 );
170 }
171
172 public function saveRobotSettings(array $robot, array $request)
173 {
174 $saveResult = new Result();
175 $documentType = $this->getDocumentType();
176
177 if (isset($robot['Properties']) && is_array($robot['Properties']))
178 {
179 $robot['Properties'] = Automation\Helper::unConvertProperties($robot['Properties'], $documentType);
180 }
181
182 $request = Automation\Helper::unConvertProperties($request, $documentType);
183
184 $copy = clone $this;
185 $copy->setRobots([$robot]);
186 $raw = $copy->template['TEMPLATE'];
187
188 $robotErrors = $v = $p = array();
189 $result = \CBPActivity::callStaticMethod(
190 $robot['Type'],
191 "GetPropertiesDialogValues",
192 [
193 $documentType,
194 $robot['Name'] ?? null,
195 &$raw,
196 &$v,
197 &$p,
198 $request,
199 &$robotErrors,
200 ]
201 );
202
203 if ($result)
204 {
205 $templateActivity = \CBPWorkflowTemplateLoader::findActivityByName($raw, $robot['Name'] ?? null);
206
207 $robotTitle = $robot['Properties']['Title'] ?? null;
208 $robot['Properties'] = $templateActivity['Properties'];
209 $robot['Properties']['Title'] = $robotTitle;
210
211 $saveResult->setData(array('robot' => $robot));
212 }
213 else
214 {
215 foreach ($robotErrors as $i => $error)
216 {
217 $errorMessage = $error['message'] ?? null;
218 $errorCode = $error['code'] ?? null;
219 $errorParameter = $error['parameter'] ?? null;
220 $saveResult->addError(new Error($errorMessage, $errorCode, ['parameter' => $errorParameter]));
221 }
222 }
223
224 return $saveResult;
225 }
226
227 public function save(array $robots, $userId, array $additional = [])
228 {
229 $userId = (int)$userId;
230 $result = new Result();
231 $templateId = !empty($this->template['ID']) ? $this->template['ID'] : 0;
232
233 if (isset($additional['PARAMETERS']) && is_array($additional['PARAMETERS']))
234 {
235 $this->template['PARAMETERS'] = $additional['PARAMETERS'];
236 }
237 if (isset($additional['CONSTANTS']) && is_array($additional['CONSTANTS']))
238 {
239 $this->template['CONSTANTS'] = $additional['CONSTANTS'];
240 }
241
242 if ($templateId)
243 {
244 $templateResult = $this->updateTemplateRobots($robots, $userId);
245 }
246 else
247 {
248 $this->setRobots($robots);
249 $templateResult = $this->addBizprocTemplate($userId);
250 }
251
252 if ($templateResult->isSuccess())
253 {
254 $resultData = $templateResult->getData();
255 if (isset($resultData['ID']))
256 {
257 $this->template['ID'] = $resultData['ID'];
258 }
259 }
260 else
261 {
262 $result->addErrors($templateResult->getErrors());
263 }
264
265 return $result;
266 }
267
268 public function setRobots(array $robots)
269 {
270 $this->robots = array();
271 $this->isExternalModified = null;
272 foreach ($robots as $robot)
273 {
274 if (is_array($robot))
275 $robot = new Robot($robot);
276
277 if (!($robot instanceof Robot))
278 {
279 throw new ArgumentException('Robots array is incorrect', 'robots');
280 }
281
282 $this->robots[] = $robot;
283 }
284
285 $this->unConvertTemplate();// make bizproc template
286
287 return $this;
288 }
289
294 public function toArray()
295 {
296 $result = [
297 'ID' => $this->getId(),
298 'DOCUMENT_TYPE' => $this->getDocumentType(),
299 'DOCUMENT_STATUS' => $this->template['DOCUMENT_STATUS'],
300 'PARAMETERS' => $this->template['PARAMETERS'],
301 'CONSTANTS' => $this->template['CONSTANTS'],
302 'VARIABLES' => $this->template['VARIABLES'] ?? [],
303 ];
304
305 $result['IS_EXTERNAL_MODIFIED'] = $this->isExternalModified();
306 $result['ROBOTS'] = array();
307
308 foreach ($this->getRobots() as $robot)
309 {
310 $result['ROBOTS'][] = $robot->toArray();
311 }
312
313 return $result;
314 }
315
316 public static function getAvailableRobots(array $documentType)
317 {
318 $key = implode('@', $documentType);
319 if (!isset(static::$availableActivities[$key]))
320 {
321 static::$availableActivities[$key] = \CBPRuntime::getRuntime()
322 ->searchActivitiesByType('robot_activity', $documentType);
323 }
324 return static::$availableActivities[$key];
325 }
326
327 protected static function getAvailableRobotClasses(array $documentType)
328 {
329 $key = implode('@', $documentType);
330 if (!isset(static::$availableActivityClasses[$key]))
331 {
332 static::$availableActivityClasses[$key] = array();
333 $activities = static::getAvailableRobots($documentType);
334 foreach ($activities as $activity)
335 {
336 static::$availableActivityClasses[$key][] = $activity['CLASS'];
337 }
338 }
339 return static::$availableActivityClasses[$key];
340 }
341
342 protected function addBizprocTemplate($userId)
343 {
344 $userId = (int)$userId;
345 $documentType = $this->getDocumentType();
346
347 $raw = $this->template;
348 $raw['DOCUMENT_TYPE'] = $documentType;
349 $raw['NAME'] = $raw['NAME'] ?? $this->makeTemplateName();
350 $raw['USER_ID'] = $userId;
351 $raw['MODIFIER_USER'] = new \CBPWorkflowTemplateUser($userId);
352
353 $result = new Result();
354 try
355 {
356 $raw['ID'] = \CBPWorkflowTemplateLoader::add($raw, $userId === 1);
357 $result->setData(array('ID' => $raw['ID']));
358
359 $raw['MODULE_ID'] = $documentType[0];
360 $raw['ENTITY'] = $documentType[1];
361 $raw['DOCUMENT_TYPE'] = $documentType[2];
362 $raw['PARAMETERS'] = [];
363 $raw['CONSTANTS'] = [];
364 $this->template = $raw;
365 }
366 catch (\Exception $e)
367 {
368 $result->addError(new Error($e->getMessage()));
369 }
370
371 return $result;
372 }
373
374 protected function makeTemplateName()
375 {
376 $msg = Loc::getMessage('BIZPROC_AUTOMATION_TEMPLATE_NAME', [
377 '#STATUS#' => $this->template['DOCUMENT_STATUS']
378 ]);
379
380 if ($this->autoExecuteType === \CBPDocumentEventType::Script)
381 {
382 $msg = Loc::getMessage('BIZPROC_AUTOMATION_TEMPLATE_SCRIPT_NAME');
383 }
384
385 return $msg;
386 }
387
388 private function updateTemplateRobots(array $robots, int $userId): Result
389 {
390 $templateId = $this->template['ID'];
391 $result = new Result();
392
393 $errors = $this->validateUpdatedRobots($robots, new \CBPWorkflowTemplateUser($userId));
394 if (!$errors->isEmpty())
395 {
396 $result->addErrors($errors->getValues());
397
398 return $result;
399 }
400
401 $this->setRobots($robots);
402 $updateFields = [
403 'TEMPLATE' => $this->template['TEMPLATE'],
404 'PARAMETERS' => $this->template['PARAMETERS'],
405 'VARIABLES' => [],
406 'CONSTANTS' => $this->template['CONSTANTS'],
407 'USER_ID' => $userId,
408 'MODIFIER_USER' => new \CBPWorkflowTemplateUser($userId),
409 ];
410
411 if (isset($this->template['NAME']))
412 {
413 $updateFields['NAME'] = $this->template['NAME'];
414 }
415
416 try
417 {
418 \CBPWorkflowTemplateLoader::update($templateId, $updateFields, false, false);
419 }
420 catch (\Exception $e)
421 {
422 $result->addError(new Error($e->getMessage()));
423 }
424
425 return $result;
426 }
427
428 private function validateUpdatedRobots(array $robots, \CBPWorkflowTemplateUser $user): ErrorCollection
429 {
430 $errors = new ErrorCollection();
431 $loader = \CBPWorkflowTemplateLoader::GetLoader();
432 $originalRobots = $this->getRobots();
433
434 $isSameRobot = function ($lhsRobot, $rhsRobot) {
435 return $lhsRobot->getName() === $rhsRobot->getName();
436 };
437
439 foreach ($robots as $robot)
440 {
441 if (is_array($robot))
442 {
443 $robot = new Robot($robot);
444 }
445 if (!($robot instanceof Robot))
446 {
447 $errors->setError(new Error('Robots array is incorrect'));
448 }
449 if (!$errors->isEmpty())
450 {
451 break;
452 }
453
454 $indexOfFoundRobot = -1;
455 foreach ($originalRobots as $index => $originalRobot)
456 {
457 if ($isSameRobot($robot, $originalRobot))
458 {
459 $indexOfFoundRobot = $index;
460 break;
461 }
462 }
463
464 if ($indexOfFoundRobot < 0 || !$this->areRobotsEqual($robot, $originalRobots[$indexOfFoundRobot]))
465 {
466 $sequence = $this->convertRobotToSequenceActivity($robot);
467 foreach ($loader->ValidateTemplate($sequence, $user) as $rawError)
468 {
469 $errors->setError(new Error(trim($rawError['message'])));
470 }
471 unset($originalRobots[$indexOfFoundRobot]);
472 }
473 }
474
475 return $errors;
476 }
477
478 private function areRobotsEqual(Robot $lhsRobot, Robot $rhsRobot): bool
479 {
480 $lhsCondition = $lhsRobot->getCondition() ?? new ConditionGroup();
481 $rhsCondition = $rhsRobot->getCondition() ?? new ConditionGroup();
482
483 $lhsDelay = $lhsRobot->getDelayInterval();
484 $rhsDelay = $rhsRobot->getDelayInterval();
485 if (!isset($lhsDelay) || $lhsDelay->isNow())
486 {
487 $lhsDelay = new DelayInterval();
488 }
489 if (!isset($rhsDelay) || $rhsDelay->isNow())
490 {
491 $rhsDelay = new DelayInterval();
492 }
493
494 return
495 $lhsCondition->toArray()['items'] === $rhsCondition->toArray()['items']
496 && $lhsDelay->toArray() === $rhsDelay->toArray()
497 && $lhsRobot->getBizprocActivity() === $rhsRobot->getBizprocActivity()
498 ;
499 }
500
501 protected function updateBizprocTemplate($id, $userId)
502 {
503 $raw = $this->template;
504 $result = new Result();
505
506 $updateFields = [
507 'TEMPLATE' => $raw['TEMPLATE'],
508 'PARAMETERS' => $raw['PARAMETERS'],
509 'VARIABLES' => [],
510 'CONSTANTS' => $raw['CONSTANTS'],
511 'USER_ID' => $userId,
512 'MODIFIER_USER' => new \CBPWorkflowTemplateUser($userId),
513 ];
514
515 if (isset($raw['NAME']))
516 {
517 $updateFields['NAME'] = $raw['NAME'];
518 }
519
520 try
521 {
522 \CBPWorkflowTemplateLoader::update($id, $updateFields);
523 }
524 catch (\Exception $e)
525 {
526 $result->addError(new Error($e->getMessage()));
527 }
528
529 return $result;
530 }
531
532 protected function convertTemplate()
533 {
534 $this->robots = array();
535
536 $raw = $this->template;
537 if (!is_array($raw) || !isset($raw['TEMPLATE']))
538 {
539 return false; // BP template is lost.
540 }
541
542 /*if (!empty($raw['PARAMETERS']) || !empty($raw['VARIABLES']) || !empty($raw['CONSTANTS']))
543 {
544 $this->isExternalModified = true;
545 return false; // modified or incorrect.
546 }*/
547
548 if (empty($raw['TEMPLATE'][0]['Children']) || !is_array($raw['TEMPLATE'][0]['Children']))
549 return true;
550
551 if (count($raw['TEMPLATE'][0]['Children']) > 1)
552 {
553 $this->isExternalModified = true;
554 return false; // modified or incorrect.
555 }
556
557 $parallelActivity = $raw['TEMPLATE'][0]['Children'][0];
558 if (!$parallelActivity || $parallelActivity['Type'] !== static::$parallelActivityType)
559 {
560 $this->isExternalModified = true;
561 return false; // modified or incorrect.
562 }
563
564 foreach ($parallelActivity['Children'] as $sequence)
565 {
566 $delay = $condition = null;
567 $robotsCnt = 0;
568 foreach ($sequence['Children'] as $activity)
569 {
570 if (
571 $activity['Type'] === static::$delayActivityType
572 || $activity['Type'] === static::$robotDelayActivityType)
573 {
574 $delay = $activity;
575 continue;
576 }
577
578 if ($activity['Type'] === static::$conditionActivityType)
579 {
580 $condition = ConditionGroup::convertBizprocActivity($activity, $this->getDocumentType(), $this);
581 if ($condition === false)
582 {
583 $this->isExternalModified = true;
584 $this->robots = array();
585 return false; // modified or incorrect.
586 }
587 }
588
589 if (!$this->isRobot($activity))
590 {
591 $this->isExternalModified = true;
592 $this->robots = array();
593 return false; // modified or incorrect.
594 }
595
596 $robotActivity = new Robot($activity);
597 if ($delay !== null)
598 {
599 $delayInterval = DelayInterval::createFromActivityProperties($delay['Properties']);
600 $robotActivity->setDelayInterval($delayInterval);
601 $robotActivity->setDelayName($delay['Name']);
602 $delay = null;
603 }
604
605 if ($condition !== null)
606 {
607 $robotActivity->setCondition($condition);
608 $condition = null;
609 }
610
611 if ($robotsCnt > 0)
612 {
613 $robotActivity->setExecuteAfterPrevious();
614 }
615
616 ++$robotsCnt;
617 $this->robots[] = $robotActivity;
618 }
619 }
620
621 $this->isConverted = true;
622 return $this->robots;
623 }
624
625 protected function unConvertTemplate()
626 {
627 $documentType = $this->getDocumentType();
628 $this->template = [
629 'ID' => $this->getId(),
630 'MODULE_ID' => $documentType[0],
631 'ENTITY' => $documentType[1],
632 'DOCUMENT_TYPE' => $documentType[2],
633 'DOCUMENT_STATUS' => $this->template['DOCUMENT_STATUS'],
634 'NAME' => $this->template['NAME'] ?? $this->makeTemplateName(),
635 'AUTO_EXECUTE' => $this->autoExecuteType,
636 'TEMPLATE' => [[
637 'Type' => 'SequentialWorkflowActivity',
638 'Name' => 'Template',
639 'Properties' => ['Title' => 'Bizproc Automation template'],
640 'Children' => [],
641 ]],
642 'PARAMETERS' => $this->template['PARAMETERS'],
643 'CONSTANTS' => $this->template['CONSTANTS'],
644 'SYSTEM_CODE' => 'bitrix_bizproc_automation',
645 ];
646
647 if ($this->robots)
648 {
649 $parallelActivity = $this->createParallelActivity();
650 $sequence = $this->createSequenceActivity();
651
652 foreach ($this->robots as $i => $robot)
653 {
654 if ($i !== 0 && !$robot->isExecuteAfterPrevious())
655 {
656 $parallelActivity['Children'][] = $sequence;
657 $sequence = $this->convertRobotToSequenceActivity($robot);
658 }
659 else
660 {
661 $sequence['Children'] = array_merge(
662 $sequence['Children'],
663 $this->convertRobotToSequenceActivity($robot)['Children']
664 );
665 }
666 }
667
668 $parallelActivity['Children'][] = $sequence;
669
670 if (count($parallelActivity['Children']) < 2)
671 {
672 $parallelActivity['Children'][] = $this->createSequenceActivity();
673 }
674
675 $this->template['TEMPLATE'][0]['Children'][] = $parallelActivity;
676 }
677 $this->robots = null;
678 $this->isConverted = false;
679 }
680
681 private function convertRobotToSequenceActivity(Robot $robot): array
682 {
683 $sequence = $this->createSequenceActivity();
684
685 $delayInterval = $robot->getDelayInterval();
686 if ($delayInterval && !$delayInterval->isNow())
687 {
688 $delayName = $robot->getDelayName();
689 if (!$delayName)
690 {
691 $delayName = Robot::generateName();
692 $robot->setDelayName($delayName);
693 }
694
695 $sequence['Children'][] = $this->createDelayActivity(
696 $delayInterval->toActivityProperties($this->getDocumentType()),
697 $delayName
698 );
699 }
700
701 $activity = $robot->getBizprocActivity();
702 $condition = $robot->getCondition();
703
704 if ($condition && $condition->getItems())
705 {
706 $activity = $condition->createBizprocActivity($activity, $this->getDocumentType(), $this);
707 }
708
709 $sequence['Children'][] = $activity;
710
711 return $sequence;
712 }
713
714 protected function isRobot(array $activity)
715 {
716 if (!in_array($activity['Type'], static::getAvailableRobotClasses($this->getDocumentType())))
717 return false;
718
719 if (!empty($activity['Children']))
720 return false;
721 return true;
722 }
723
727 public function getRobots()
728 {
729 if ($this->robots === null)
730 $this->convertTemplate();
731
732 return $this->robots;
733 }
734
740 public function getRobotByName(string $name): ?Robot
741 {
742 foreach ($this->getRobots() as $robot)
743 {
744 if ($name === $robot->getName())
745 {
746 return $robot;
747 }
748 }
749 return null;
750 }
751
752 public function getRobotsByNames(array $names): array
753 {
754 return array_uintersect($this->getRobots(), $names, function ($lhs, $rhs) {
755 $lhsName = is_string($lhs) ? $lhs : $lhs->getName();
756 $rhsName = is_string($rhs) ? $rhs : $rhs->getName();
757
758 return strcmp($lhsName, $rhsName);
759 });
760 }
761
765 public function getActivities()
766 {
767 return $this->template['TEMPLATE'];
768 }
769
770 public function getModified(): ?DateTime
771 {
772 return $this->template['MODIFIED'] ?? null;
773 }
774
779 public function isExternalModified()
780 {
781 if ($this->isExternalModified === null)
782 $this->getRobots();
783
784 return ($this->isExternalModified === true);
785 }
786
787 public function getDocumentType(): array
788 {
789 return [$this->template['MODULE_ID'], $this->template['ENTITY'], $this->template['DOCUMENT_TYPE']];
790 }
791
792 public function getProperty($object, $field): ?array
793 {
794 switch ($object)
795 {
796 case 'Template':
797 return $this->template['PARAMETERS'][$field] ?? null;
798 case 'Variable':
799 return $this->template['VARIABLES'][$field] ?? null;
800 case 'Constant':
801 return $this->template['CONSTANTS'][$field] ?? null;
802 case 'GlobalConst':
803 return Bizproc\Workflow\Type\GlobalConst::getVisibleById($field, $this->getDocumentType());
804 case 'GlobalVar':
805 return Bizproc\Workflow\Type\GlobalVar::getVisibleById($field, $this->getDocumentType());
806 case 'Document':
807 static $fields;
808 if (!$fields)
809 {
810 $documentService = \CBPRuntime::GetRuntime(true)->getDocumentService();
811 $fields = $documentService->GetDocumentFields($this->getDocumentType());
812 }
813
814 return $fields[$field] ?? null;
815 default:
816 if ($this->isConverted)
817 {
818 return $this->findRobotProperty($object, $field);
819 }
820 else
821 {
822 return $this->findActivityProperty($object, $field);
823 }
824 }
825 }
826
827 private function findRobotProperty($object, $field): ?array
828 {
829 $robot = $this->getRobotByName($object);
830 return $robot ? $robot->getReturnProperty($field) : null;
831 }
832
833 private function findActivityProperty($object, $field): ?array
834 {
835 $activity = self::findTemplateActivity($this->template['TEMPLATE'], $object);
836 if (!$activity)
837 {
838 return null;
839 }
840
841 $props = \CBPRuntime::GetRuntime(true)->getActivityReturnProperties($activity['Type']);
842 return $props[$field] ?? null;
843 }
844
845 private static function findTemplateActivity(array $template, $id)
846 {
847 foreach ($template as $activity)
848 {
849 if ($activity['Name'] === $id)
850 {
851 return $activity;
852 }
853 if (is_array($activity['Children']))
854 {
855 $found = self::findTemplateActivity($activity['Children'], $id);
856 if ($found)
857 {
858 return $found;
859 }
860 }
861 }
862 return null;
863 }
864
865 private function createSequenceActivity()
866 {
867 return array(
868 'Type' => static::$sequenceActivityType,
869 'Name' => Robot::generateName(),
870 'Properties' => [
871 'Title' => 'Automation sequence',
872 ],
873 'Children' => [],
874 );
875 }
876
877 private function createParallelActivity()
878 {
879 return array(
880 'Type' => static::$parallelActivityType,
881 'Name' => Robot::generateName(),
882 'Properties' => array(
883 'Title' => Loc::getMessage('BIZPROC_AUTOMATION_PARALLEL_ACTIVITY'),
884 ),
885 'Children' => [],
886 );
887 }
888
889 private function createDelayActivity(array $delayProperties, $delayName)
890 {
891 if (!isset($delayProperties['Title']))
892 {
893 $delayProperties['Title'] = Loc::getMessage('BIZPROC_AUTOMATION_ROBOT_DELAY_ACTIVITY');
894 }
895
896 return array(
897 'Type' => static::$robotDelayActivityType,
898 'Name' => $delayName,
899 'Properties' => $delayProperties,
900 'Children' => [],
901 );
902 }
903}
static convertBizprocActivity(array &$activity, array $documentType, Template $template)
static createFromActivityProperties(array $properties)
deleteRobots(array $robots, int $userId)
Definition: template.php:90
static getAvailableRobotClasses(array $documentType)
Definition: template.php:327
static getAvailableRobots(array $documentType)
Definition: template.php:316
__construct(array $documentType, $documentStatus=null)
Definition: template.php:47
getRobotSettingsDialog(array $robot, $request=null)
Definition: template.php:143
save(array $robots, $userId, array $additional=[])
Definition: template.php:227
saveRobotSettings(array $robot, array $request)
Definition: template.php:172
static loadMessages($file)
Definition: loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition: loc.php:29
trait Error
Definition: error.php:11