Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
copyimplementer.php
1<?php
2namespace Bitrix\Main\Copy;
3
5
10abstract class CopyImplementer
11{
15 protected $result;
16
21 protected $ufIgnoreList = [];
23
24 public function __construct()
25 {
26 $this->result = new Result();
27 }
28
32 public function getErrors()
33 {
34 return $this->result->getErrors();
35 }
36
42 public function setUserFieldManager(\CUserTypeManager $userTypeManager)
43 {
44 $this->userTypeManager = $userTypeManager;
45 }
46
52 public function setUfIgnoreList(array $ufIgnoreList): void
53 {
54 $this->ufIgnoreList = $ufIgnoreList;
55 }
56
62 public function setExecutiveUserId(int $executiveUserId): void
63 {
64 $this->executiveUserId = $executiveUserId;
65 }
66
67 protected function copyUfFields(int $entityId, int $copiedEntityId, string $ufObject)
68 {
69 if (!$this->userTypeManager)
70 {
71 return;
72 }
73
74 $this->userTypeManager->copy($ufObject, $entityId, $copiedEntityId,
75 $this, $this->executiveUserId, $this->ufIgnoreList);
76 }
77
85 abstract public function add(Container $container, array $fields);
86
94 abstract public function getFields(Container $container, $entityId);
95
103 abstract public function prepareFieldsToCopy(Container $container, array $fields);
104
113 abstract public function copyChildren(Container $container, $entityId, $copiedEntityId);
114
119 protected function getResult(array $results = [])
120 {
121 $copyResult = new Result();
122
123 $data = [];
124 foreach ($results as $result)
125 {
126 $data = $data + $result->getData();
127 if ($result->getErrors())
128 {
129 $copyResult->addErrors($result->getErrors());
130 }
131 }
132
133 if ($data)
134 {
135 $copyResult->setData($data);
136 }
137
138 return $copyResult;
139 }
140}
setUfIgnoreList(array $ufIgnoreList)
setUserFieldManager(\CUserTypeManager $userTypeManager)
setExecutiveUserId(int $executiveUserId)
getFields(Container $container, $entityId)
add(Container $container, array $fields)
copyUfFields(int $entityId, int $copiedEntityId, string $ufObject)
copyChildren(Container $container, $entityId, $copiedEntityId)
prepareFieldsToCopy(Container $container, array $fields)