17 if (is_a($template, Template::class))
19 $this->addAutomationShards($template);
25 private function addAutomationShards(
Template $template)
27 $lastSavedTemplateShards = $this->findTemplateShards($template->
getId());
30 $lastSavedTemplateShards
32 && $lastSavedTemplateShards->getModified()->toString() === $template->
getModified()->toString()
35 $this->setTemplateShardsId($lastSavedTemplateShards->getId());
40 foreach ($template->
getRobots() as $robot)
42 $shards[] = $robot->toArray();
49 ->setTemplateId($template->
getId())
53 $savingResult = $templateShards->save();
54 $this->setTemplateShardsId($savingResult->getId());
58 private function findTemplateShards(
int $templateId): ?TemplateShards
61 'select' => [
'ID',
'MODIFIED'],
62 'filter' => [
'TEMPLATE_ID' => $templateId],
63 'order' => [
'MODIFIED' =>
'DESC'],
static getList(array $parameters=array())
static createObject($setDefaultValues=true)