37 $this->params[
'ENTITY_VALUE_ID'] = $this->params[
'ENTITY_VALUE_ID'] ??
null;
38 $this->params[
'VALUE_ID'] = $this->params[
'VALUE_ID'] ??
null;
90 if (!array_key_exists($id, self::$instance))
92 self::$instance[$id] =
new static(
$params);
94 return self::$instance[$id];
104 if(!isset($this->loadedAttachedObjects[$id]))
106 $this->loadedAttachedObjects[$id] = \Bitrix\Vote\Attachment\Manager::loadFromAttachId($id);
108 return $this->loadedAttachedObjects[$id];
119 if(!isset($this->loadedAttachedObjects[$id1]))
122 $attach = \Bitrix\Vote\Attachment\Manager::loadFromVoteId(array(
123 "ENTITY_ID" => ($this->params[
"ENTITY_VALUE_ID"] ?: $this->params[
"VALUE_ID"]),
124 "ENTITY_TYPE" => $entityType,
125 "MODULE_ID" => $moduleId), $id);
126 $this->loadedAttachedObjects[$id1] = $attach;
128 return $this->loadedAttachedObjects[$id1];
137 return \Bitrix\Vote\Attachment\Manager::loadEmptyAttach(array(
138 "ENTITY_ID" => ($this->params[
"ENTITY_VALUE_ID"] ?: $this->params[
"VALUE_ID"]),
139 "ENTITY_TYPE" => $entityType,
140 "MODULE_ID" => $moduleId), array(
141 "CHANNEL_ID" => $this->params[
"SETTINGS"][
"CHANNEL_ID"]
152 "ENTITY_ID" => ($this->params[
"ENTITY_VALUE_ID"] ?: $this->params[
"VALUE_ID"]),
153 "=ENTITY_TYPE" => $entityType,
154 "=MODULE_ID" => $moduleId);
155 return \Bitrix\Vote\Attachment\Manager::loadFromEntity($res);
180 $defaultConnectors = $this->getDefaultConnectors();
181 $entityType = mb_strtolower($entityType);
183 if(isset($defaultConnectors[$entityType]))
184 return $defaultConnectors[$entityType];
185 if (($connector = $this->getAdditionalConnector($entityType)) !==
null)
197 return array_merge($this->getDefaultConnectors(), $this->getAdditionalConnectors());
200 private function getDefaultConnectors()
209 private function getAdditionalConnectors()
211 if($this->additionalConnectorList ===
null)
213 $this->buildAdditionalConnectorList();
219 private function getAdditionalConnector($entityType)
226 private function buildAdditionalConnectorList()
228 $this->additionalConnectorList = array();
230 $event =
new Event(
"vote",
"onBuildAdditionalConnectorList");
233 foreach($event->getResults() as $evenResult)
235 if($evenResult->getType() != EventResult::SUCCESS)
240 $result = $evenResult->getParameters();
241 if(!is_array($result))
243 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Must be array.');
246 foreach($result as $connector)
248 if(empty($connector[
'ENTITY_TYPE']))
250 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Could not find ENTITY_TYPE.');
253 if(empty($connector[
'MODULE_ID']))
255 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Could not find MODULE_ID.');
258 if(empty($connector[
'CLASS']))
260 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Could not find CLASS.');
263 if(is_string($connector[
'CLASS']) && class_exists($connector[
'CLASS']) && is_a($connector[
'CLASS'], Connector::class,
true))
265 $this->additionalConnectorList[mb_strtolower($connector[
'ENTITY_TYPE'])] = array(
267 $connector[
'MODULE_ID']
272 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Could not find class by CLASS.');
288 $APPLICATION->IncludeComponent(
297 array(
"HIDE_ICONS" =>
"Y")
311 $APPLICATION->IncludeComponent(
319 array(
"HIDE_ICONS" =>
"Y")
329 return $this->errorCollection->toArray();