Bitrix-D7 22.6
 
Загрузка...
Поиск...
Не найдено
WorkflowContext.php
1<?php
2
4
8
9class WorkflowContext extends Entity\EO_DebuggerSessionWorkflowContext
10{
15 public function addTemplateShards($template): self
16 {
17 if (is_a($template, Template::class))
18 {
19 $this->addAutomationShards($template);
20 }
21
22 return $this;
23 }
24
25 private function addAutomationShards(Template $template)
26 {
27 $lastSavedTemplateShards = $this->findTemplateShards($template->getId());
28
29 if (
30 $lastSavedTemplateShards
31 && $template->getModified()
32 && $lastSavedTemplateShards->getModified()->toString() === $template->getModified()->toString()
33 )
34 {
35 $this->setTemplateShardsId($lastSavedTemplateShards->getId());
36 }
37 else
38 {
39 $shards = [];
40 foreach ($template->getRobots() as $robot)
41 {
42 $shards[] = $robot->toArray();
43 }
44
46 $templateShards
47 ->setShards($shards)
48 ->setModified($template->getModified())
49 ->setTemplateId($template->getId())
51 ;
52
53 $savingResult = $templateShards->save();
54 $this->setTemplateShardsId($savingResult->getId());
55 }
56 }
57
58 private function findTemplateShards(int $templateId): ?TemplateShards
59 {
61 'select' => ['ID', 'MODIFIED'],
62 'filter' => ['TEMPLATE_ID' => $templateId],
63 'order' => ['MODIFIED' => 'DESC'],
64 'limit' => 1,
65 ])->fetchObject();
66 }
67}
static getList(array $parameters=array())
static createObject($setDefaultValues=true)