7class Item implements \JsonSerializable
62 $id = $options[
'id'] ??
null;
63 if ((is_string(
$id) &&
$id !==
'') || is_int(
$id))
80 $this->
addTab($options[
'tabs'] ??
null);
82 $this->
setTitle($options[
'title'] ??
null);
85 $this->
setCaption($options[
'caption'] ??
null);
87 if (isset($options[
'captionOptions']) && is_array($options[
'captionOptions']))
92 if (isset($options[
'avatar']) && is_string($options[
'avatar']))
97 if (isset($options[
'avatarOptions']) && is_array($options[
'avatarOptions']))
102 if (isset($options[
'textColor']) && is_string($options[
'textColor']))
107 if (isset($options[
'link']) && is_string($options[
'link']))
109 $this->
setLink($options[
'link']);
114 if (isset($options[
'badges']) && is_array($options[
'badges']))
119 if (isset($options[
'badgesOptions']) && is_array($options[
'badgesOptions']))
124 if (isset($options[
'searchable']) && is_bool($options[
'searchable']))
129 if (isset($options[
'selected']) && is_bool($options[
'selected']))
134 if (isset($options[
'saveable']) && is_bool($options[
'saveable']))
139 if (isset($options[
'deselectable']) && is_bool($options[
'deselectable']))
144 if (isset($options[
'hidden']) && is_bool($options[
'hidden']))
149 if (isset($options[
'sort']) && is_int($options[
'sort']))
151 $this->
setSort($options[
'sort']);
154 if (isset($options[
'availableInRecentTab']) && is_bool($options[
'availableInRecentTab']))
159 if (isset($options[
'customData']) && is_array($options[
'customData']))
164 if (isset($options[
'nodeOptions']) && is_array($options[
'nodeOptions']))
169 if (isset($options[
'tagOptions']) && is_array($options[
'tagOptions']))
174 if (!empty($options[
'children']) && is_array($options[
'children']))
197 if (is_string($type) || $type ===
null)
199 $this->entityType = $type;
297 if ($this->captionOptions ===
null)
332 if ($this->avatarOptions ===
null)
399 if (is_array($badge) && !empty($badge))
401 $this->badges[] = $badge;
428 if ($this->badgesOptions ===
null)
443 if (is_string($tabId) && !empty($tabId))
445 $this->tabs[] = $tabId;
447 else if (is_array($tabId))
449 $this->tabs = array_merge($this->tabs, $tabId);
457 if ($this->children ===
null)
469 unset($childOptions[
'tabs']);
471 $child =
new Item($childOptions);
483 $this->
getDialog()->handleItemAdd($item);
498 if ($this->nodeOptions ===
null)
515 if ($this->tagOptions ===
null)
530 $this->selected = $flag;
542 $this->searchable = $flag;
554 $this->saveable = $flag;
566 $this->deselectable = $flag;
578 $this->hidden = $flag;
590 $this->availableInRecentTab = $flag;
607 if ($this->customData ===
null)
629 $this->contextSort =
$sort;
641 $this->globalSort =
$sort;
665 return $this->serializeRecursive($this);
668 private function serializeRecursive($data)
670 if ($data instanceof \JsonSerializable)
672 $data = $data->jsonSerialize();
675 if (is_array($data) || $data instanceof \Traversable)
677 foreach ($data as $key => $item)
679 $data[$key] = $this->serializeRecursive($item);
689 'id' => $this->
getId(),
716 $json[
'selected'] =
true;
721 $json[
'searchable'] =
false;
726 $json[
'saveable'] =
false;
731 $json[
'deselectable'] =
false;
736 $json[
'hidden'] =
true;
739 if ($this->avatarOptions !==
null && $this->
getAvatarOptions()->count() > 0)
749 if ($this->badgesOptions !==
null && $this->
getBadgesOptions()->count() > 0)
754 if ($this->customData !==
null && $this->
getCustomData()->count() > 0)
759 if ($this->nodeOptions !==
null && $this->
getNodeOptions()->count() > 0)
764 if ($this->tagOptions !==
null && $this->
getTagOptions()->count() > 0)
769 if ($this->children !==
null && $this->
getChildren()->count() > 0)
776 $json[
'tabs'] = $this->
getTabs();
794 if ($this->{
'get'.$field}() !==
null)
796 $json[$field] = $this->{
'get'.$field}();
setSaveable(bool $flag=true)
__construct(array $options)
setNodeOptions(array $nodeOptions)
setDeselectable(bool $flag=true)
setEntityType(string $type)
setDialog(Dialog $dialog)
setTextColor(?string $textColor)
setBadgesOptions(array $badgesOptions)
setHidden(bool $flag=true)
setAvatarOptions(array $avatarOptions)
setSupertitle($supertitle)
setCaptionOptions(array $captionOptions)
setSearchable(bool $flag=true)
addChildren(array $children)
setSelected(bool $flag=true)
setContextSort(?int $sort)
setGlobalSort(?int $sort)
setAvailableInRecentTab(bool $flag=true)
setAvatar(?string $avatar)
setCustomData(array $customData)
setTagOptions(array $nodeOptions)
static isValidText($text)