/** * Returns the item reference description. * @param \RainLab\Pages\Classes\MenuItem $item Specifies the menu item * @return string */ protected function getReferenceDescription($item) { if ($this->typeListCache === false) { $this->typeListCache = $item->getTypeOptions(); } if (!isset($this->typeInfoCache[$item->type])) { $this->typeInfoCache[$item->type] = MenuItem::getTypeInfo($item->type); } if (isset($this->typeInfoCache[$item->type])) { $result = $this->typeListCache[$item->type]; if ($item->type !== 'url') { if (isset($this->typeInfoCache[$item->type]['references'])) { $result .= ': ' . $this->findReferenceName($item->reference, $this->typeInfoCache[$item->type]['references']); } } else { $result .= ': ' . $item->url; } } else { $result = trans('rainlab.pages::lang.menuitem.unknown_type'); } return $result; }
public function onGetMenuItemTypeInfo() { $type = Request::input('type'); return ['menuItemTypeInfo' => MenuItem::getTypeInfo($type)]; }
/** * Saves the object to the disk. */ public function save() { if ($this->itemData !== false) { $this->items = MenuItem::initFromArray($this->itemData); } $contentData = ['name' => $this->name, 'items' => $this->itemData ? $this->itemData : []]; $dumper = new YamlDumper(); $this->content = $dumper->dump($contentData, 20, 0, false, true); return parent::save(); }
/** * Returns a default value for items attribute. * Items are objects of the \RainLab\Pages\Classes\MenuItem class. * @return array */ public function getItemsAttribute() { if (array_key_exists('items', $this->attributes)) { return $this->attributes['items']; } if ($items = array_get($this->parseContent(), 'items')) { $itemObjects = MenuItem::initFromArray($items); } else { $itemObjects = []; } return $this->attributes['items'] = $itemObjects; }