16 protected const ENTITY_MAP_FIELDS = [
'entityId',
'entityData1',
'entityData2',
'entityData3'];
31 if (in_array($field, self::ENTITY_MAP_FIELDS,
true) && is_array($map))
33 $this->entityMap[$field] = array_values($map);
51 if (!count($this->entityData) || $force)
53 $this->entityData = $this->unmapEntity();
59 private function unmapEntity(): array
62 foreach ($this->
getEntityMap() as $entityType => $entityFields)
64 if (!count($entityFields))
69 if ($this->$entityType)
71 $data = explode(self::ENTITY_SEPARATOR, $this->$entityType);
72 if (count($entityFields) === count($data))
74 $result[$entityType] = array_combine($entityFields, $data);
78 $result[$entityType] = $data;
83 $result[$entityType] = array_fill_keys($entityFields,
null);
103 if (empty($params[
'ENTITY_TYPE']) || empty($params[
'ENTITY_ID']))
108 $row = ChatTable::query()
109 ->setSelect([
'ID',
'TYPE',
'ENTITY_TYPE',
'ENTITY_ID'])
110 ->where(
'ENTITY_TYPE', $params[
'ENTITY_TYPE'])
111 ->where(
'ENTITY_ID', $params[
'ENTITY_ID'])
118 'ID' => (
int)$row[
'ID'],
119 'TYPE' => $row[
'TYPE'],
120 'ENTITY_TYPE' => $row[
'ENTITY_TYPE'],
121 'ENTITY_ID' => $row[
'ENTITY_ID'],