38 $this->params[
'ENTITY_VALUE_ID'] = $this->params[
'ENTITY_VALUE_ID'] ??
null;
39 $this->params[
'VALUE_ID'] = $this->params[
'VALUE_ID'] ??
null;
91 if (!array_key_exists($id, self::$instance))
93 self::$instance[$id] =
new static(
$params);
95 return self::$instance[$id];
105 if(!isset($this->loadedAttachedObjects[$id]))
109 return $this->loadedAttachedObjects[$id];
120 if(!isset($this->loadedAttachedObjects[$id1]))
124 "ENTITY_ID" => ($this->params[
"ENTITY_VALUE_ID"] ?: $this->params[
"VALUE_ID"]),
125 "ENTITY_TYPE" => $entityType,
127 $this->loadedAttachedObjects[$id1] = $attach;
129 return $this->loadedAttachedObjects[$id1];
138 return \Bitrix\Vote\Attachment\Manager::loadEmptyAttach(
array(
139 "ENTITY_ID" => ($this->params[
"ENTITY_VALUE_ID"] ?: $this->params[
"VALUE_ID"]),
140 "ENTITY_TYPE" => $entityType,
142 "CHANNEL_ID" => $this->params[
"SETTINGS"][
"CHANNEL_ID"]
153 "ENTITY_ID" => ($this->params[
"ENTITY_VALUE_ID"] ?: $this->params[
"VALUE_ID"]),
154 "=ENTITY_TYPE" => $entityType,
156 return \Bitrix\Vote\Attachment\Manager::loadFromEntity(
$res);
181 $defaultConnectors = $this->getDefaultConnectors();
182 $entityType = mb_strtolower($entityType);
184 if(isset($defaultConnectors[$entityType]))
185 return $defaultConnectors[$entityType];
186 if (($connector = $this->getAdditionalConnector($entityType)) !==
null)
198 return array_merge($this->getDefaultConnectors(), $this->getAdditionalConnectors());
201 private function getDefaultConnectors():
array
206 'im_message' => [ImMessageConnector::className(),
'im'],
211 private function getAdditionalConnectors()
213 if($this->additionalConnectorList ===
null)
215 $this->buildAdditionalConnectorList();
221 private function getAdditionalConnector($entityType)
228 private function buildAdditionalConnectorList()
230 $this->additionalConnectorList =
array();
232 $event =
new Event(
"vote",
"onBuildAdditionalConnectorList");
235 foreach(
$event->getResults() as $evenResult)
237 if($evenResult->getType() != EventResult::SUCCESS)
242 $result = $evenResult->getParameters();
245 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Must be array.');
250 if(empty($connector[
'ENTITY_TYPE']))
252 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Could not find ENTITY_TYPE.');
255 if(empty($connector[
'MODULE_ID']))
257 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Could not find MODULE_ID.');
260 if(empty($connector[
'CLASS']))
262 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Could not find CLASS.');
265 if(is_string($connector[
'CLASS']) && class_exists($connector[
'CLASS']) && is_a($connector[
'CLASS'], Connector::class,
true))
267 $this->additionalConnectorList[mb_strtolower($connector[
'ENTITY_TYPE'])] =
array(
269 $connector[
'MODULE_ID']
274 throw new SystemException(
'Wrong event result by building AdditionalConnectorList. Could not find class by CLASS.');
299 array(
"HIDE_ICONS" =>
"Y")
321 array(
"HIDE_ICONS" =>
"Y")
331 return $this->errorCollection->toArray();