- Модуль: ui
- Путь к файлу: ~/bitrix/modules/ui/lib/entityselector/item.php
- Класс: BitrixUIEntitySelectorItem
- Вызов: Item::jsonSerialize
public function jsonSerialize()
{
$json = [
'id' => $this->getId(),
'entityId' => $this->getEntityId(),
'title' => $this->getTitleNode() !== null ? $this->getTitleNode()->jsonSerialize() : '',
];
if ($this->getSubtitleNode() !== null)
{
$json['subtitle'] = $this->getSubtitleNode()->jsonSerialize();
}
if ($this->getSupertitleNode() !== null)
{
$json['supertitle'] = $this->getSupertitleNode()->jsonSerialize();
}
if ($this->getCaptionNode() !== null)
{
$json['caption'] = $this->getCaptionNode()->jsonSerialize();
}
if ($this->getLinkTitleNode() !== null)
{
$json['linkTitle'] = $this->getLinkTitleNode()->jsonSerialize();
}
if ($this->isSelected())
{
$json['selected'] = true;
}
if (!$this->isSearchable())
{
$json['searchable'] = false;
}
if (!$this->isSaveable())
{
$json['saveable'] = false;
}
if (!$this->isDeselectable())
{
$json['deselectable'] = false;
}
if ($this->isHidden())
{
$json['hidden'] = true;
}
if ($this->avatarOptions !== null && $this->getAvatarOptions()->count() > 0)
{
$json['avatarOptions'] = $this->getAvatarOptions()->getValues();
}
if ($this->captionOptions !== null && $this->getCaptionOptions()->count() > 0)
{
$json['captionOptions'] = $this->getCaptionOptions()->getValues();
}
if ($this->badgesOptions !== null && $this->getBadgesOptions()->count() > 0)
{
$json['badgesOptions'] = $this->getBadgesOptions()->getValues();
}
if ($this->customData !== null && $this->getCustomData()->count() > 0)
{
$json['customData'] = $this->getCustomData()->getValues();
}
if ($this->nodeOptions !== null && $this->getNodeOptions()->count() > 0)
{
$json['nodeOptions'] = $this->getNodeOptions()->getValues();
}
if ($this->tagOptions !== null && $this->getTagOptions()->count() > 0)
{
$json['tagOptions'] = $this->getTagOptions()->getValues();
}
if ($this->children !== null && $this->getChildren()->count() > 0)
{
$json['children'] = $this->getChildren();
}
if (!empty($this->getTabs()))
{
$json['tabs'] = $this->getTabs();
}
if (!empty($this->getBadges()))
{
$json['badges'] = $this->getBadges();
}
foreach ([
'entityType',
'avatar',
'textColor',
'link',
'contextSort',
'globalSort',
'sort'
] as $field)
{
if ($this->{'get'.$field}() !== null)
{
$json[$field] = $this->{'get'.$field}();
}
}
return $json;
}