1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
entity.php
См. документацию.
1<?php
3
4use Bitrix\Iblock\Copy\Implement\Element as ElementImplementer;
11
12abstract class Entity extends Stepper
13{
14 protected static $moduleId = "iblock";
15
16 protected function getContainerCollection($elementIds, array $sectionsRatio, array $enumRatio, $targetIblockId = 0)
17 {
18 $dictionary = new Dictionary([
19 'targetIblockId' => $targetIblockId,
20 'enumRatio' => $enumRatio,
21 'sectionsRatio' => $sectionsRatio,
22 ]);
23
24 return $this->fillContainerCollection($elementIds, $dictionary);
25 }
26
27 protected function fillContainerCollection(array $elementIds, Dictionary $dictionary): ContainerCollection
28 {
29 $containerCollection = new ContainerCollection();
30
31 foreach ($elementIds as $elementId)
32 {
33 $container = new Container($elementId);
34 $copyDictionary = clone $dictionary;
35 $container->setDictionary($copyDictionary);
36 unset($copyDictionary);
37
38 $containerCollection[] = $container;
39 }
40
41 return $containerCollection;
42 }
43
44 protected function getElementCopier()
45 {
46 $elementImplementer = new ElementImplementer();
47 return new EntityCopier($elementImplementer);
48 }
49
50 protected function onAfterCopy(array $queueOption)
51 {
52 $this->saveErrorOption($queueOption);
53 }
54
55 protected function getErrorOffset(EntityCopier $elementCopier): int
56 {
57 $numberIds = count($elementCopier->getMapIdsCopiedEntity());
58 $numberSuccessIds = count(array_filter($elementCopier->getMapIdsCopiedEntity()));
59 return $numberIds - $numberSuccessIds;
60 }
61
62 private function saveErrorOption(array $queueOption)
63 {
64 $mapIdsCopiedElements = $queueOption["mapIdsCopiedElements"] ?: [];
65
66 $mapIdsWithErrors = [];
67 foreach ($mapIdsCopiedElements as $elementId => $copiedElementId)
68 {
69 if (!$copiedElementId)
70 {
71 $mapIdsWithErrors[] = $elementId;
72 }
73 }
74
75 if ($mapIdsWithErrors)
76 {
77 Option::set(self::$moduleId, $this->errorName, serialize($mapIdsWithErrors));
78 }
79 }
80
81 protected function getQueue(): array
82 {
83 return $this->getOptionData($this->queueName);
84 }
85
86 protected function setQueue(array $queue): void
87 {
88 $queueId = (string) current($queue);
89 $this->checkerName = (mb_strpos($this->checkerName, $queueId) === false ?
90 $this->checkerName.$queueId : $this->checkerName);
91 $this->baseName = (mb_strpos($this->baseName, $queueId) === false ?
92 $this->baseName.$queueId : $this->baseName);
93 $this->errorName = (mb_strpos($this->errorName, $queueId) === false ?
94 $this->errorName.$queueId : $this->errorName);
95 }
96
97 protected function getQueueOption()
98 {
99 return $this->getOptionData($this->baseName);
100 }
101
102 protected function saveQueueOption(array $data)
103 {
104 Option::set(static::$moduleId, $this->baseName, serialize($data));
105 }
106
107 protected function deleteQueueOption()
108 {
109 $queue = $this->getQueue();
110 $this->setQueue($queue);
111 $this->deleteCurrentQueue($queue);
112 Option::delete(static::$moduleId, ["name" => $this->checkerName]);
113 Option::delete(static::$moduleId, ["name" => $this->baseName]);
114 }
115
116 protected function deleteCurrentQueue(array $queue): void
117 {
118 $queueId = current($queue);
119 $currentPos = array_search($queueId, $queue);
120 if ($currentPos !== false)
121 {
122 unset($queue[$currentPos]);
123 Option::set(static::$moduleId, $this->queueName, serialize($queue));
124 }
125 }
126
127 protected function isQueueEmpty()
128 {
129 $queue = $this->getOptionData($this->queueName);
130 return empty($queue);
131 }
132
133 protected function getOptionData($optionName)
134 {
135 $option = Option::get(static::$moduleId, $optionName);
136 $option = ($option !== "" ? unserialize($option, ['allowed_classes' => false]) : []);
137 return (is_array($option) ? $option : []);
138 }
139
140 protected function deleteOption($optionName)
141 {
142 Option::delete(static::$moduleId, ["name" => $optionName]);
143 }
144}
saveQueueOption(array $data)
Определения entity.php:102
getContainerCollection($elementIds, array $sectionsRatio, array $enumRatio, $targetIblockId=0)
Определения entity.php:16
deleteCurrentQueue(array $queue)
Определения entity.php:116
setQueue(array $queue)
Определения entity.php:86
deleteOption($optionName)
Определения entity.php:140
getOptionData($optionName)
Определения entity.php:133
onAfterCopy(array $queueOption)
Определения entity.php:50
static $moduleId
Определения entity.php:14
fillContainerCollection(array $elementIds, Dictionary $dictionary)
Определения entity.php:27
getErrorOffset(EntityCopier $elementCopier)
Определения entity.php:55
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$option
Определения options.php:1711
$optionName
Определения options.php:1735