Пример #1
0
 /**
  * MenuItemDetails constructor.
  * @param MenuItem $item
  * @param bool $active
  * @param int $parentPageId
  * @param bool $canonicals
  */
 public function __construct(MenuItem $item, $active = false, $parentPageId = 0, $canonicals = false)
 {
     $pageId = Path::unParsePageId($item->page_id);
     if (!$item->id && !$canonicals) {
         $item->page_id = Path::parsePageId($pageId, $parentPageId);
     }
     $this->item = $item;
     $this->page = Page::preload($pageId);
     $this->parentPageId = $parentPageId;
     $this->active = $active;
     $this->name = $item->custom_name ?: PageLang::getName($pageId);
     $this->url = $this->page && $this->page->link ? PageLang::getUrl($pageId) : Path::getFullUrl($item->page_id);
 }
 /**
  * @param int $pageId
  * @param bool $noOverride
  * @return string
  */
 public function pageUrlSegment($pageId = 0, $noOverride = false)
 {
     $pageId = $pageId ?: $this->pageId($noOverride);
     return $pageId ? PageLang::getUrl($pageId) : '';
 }