public function toArray()
{
$array = ['title' => $this->getName(), 'icon' => $this->getIcon(), 'action' => $this->getAction(), 'event' => $this->getEvent(), 'eventArguments' => $this->getEventArguments(), 'hasSettings' => $this->getHasSettings(), 'disabled' => $this->getDisabled(), 'id' => $this->getId() != null ? $this->getId() : str_replace('.', '', uniqid('', true))];
if ($this->getHeaderIcon() != null || $this->getHeaderTitle() != null) {
$array['header'] = ['title' => $this->getHeaderTitle(), 'logo' => $this->getHeaderIcon()];
}
$children = $this->getChildren();
usort($children, function (NavigationItem $a, NavigationItem $b) {
$aPosition = $a->getPosition() ?: PHP_INT_MAX;
$bPosition = $b->getPosition() ?: PHP_INT_MAX;
return $aPosition - $bPosition;
});
foreach ($children as $key => $child) {
/* @var NavigationItem $child */
$array['items'][$key] = $child->toArray();
}
return $array;
}