當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MenuItem::get方法代碼示例

本文整理匯總了PHP中MenuItem::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP MenuItem::get方法的具體用法?PHP MenuItem::get怎麽用?PHP MenuItem::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MenuItem的用法示例。


在下文中一共展示了MenuItem::get方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: buildTree

 /**
  * Recursively creates a tree from the pages array
  *
  * @param   MenuItem parent         MenuItem object under which the tree is build
  * @param   array    pageIdx        indices of pages for this tree
  */
 private function buildTree(MenuItem &$parent, $pageIdx)
 {
     foreach ($pageIdx as $i) {
         if ($this->pages[$i]->parent == $parent->get('id')) {
             $child = $parent->addChild($this->pages[$i]);
             $this->buildTree($child, array_diff($pageIdx, array($i)));
             if ($this->pid == $this->pages[$i]->id) {
                 $parent->getRoot()->setCurrentItem($child);
             }
         }
     }
 }
開發者ID:schulzp,項目名稱:stamm_leo_website,代碼行數:18,代碼來源:class.menubuilder.php

示例2: testSomething

 public function testSomething()
 {
     Config::inst()->remove('NavigationScraper', 'MenuSets');
     Config::inst()->update('NavigationScraper', 'MenuSets', array('Test' => array('PageToScrape' => 'https://www.example.com', 'CSSSelector' => '.test a')));
     $updateService = new MenuSetUpdateService();
     $updateService->scrapeConfiguredMenuSets();
     $menuItems = MenuItem::get();
     $this->assertEquals(1, count($menuItems));
     $menuItem = $menuItems->first();
     $this->assertEquals('Test', $menuItem->MenuSet);
     $this->assertEquals('Hello world!', $menuItem->LinkText);
     $this->assertEquals('https://www.example.com/hello-world', $menuItem->LinkHref);
 }
開發者ID:helpfulrobot,項目名稱:deptinternalaffairsnz-silverstripe-navigation-scraper,代碼行數:13,代碼來源:MenuSetUpdateServiceTest.php

示例3: scrapeConfiguredMenuSets

 /**
  * Scrapes all configured MenuSets under the NavigationScraper configuration item
  */
 public function scrapeConfiguredMenuSets()
 {
     $menuSetsToScrape = Config::inst()->get('NavigationScraper', 'MenuSets');
     $scraperService = Injector::inst()->create('NavigationScraperService');
     foreach ($menuSetsToScrape as $menuSet => $details) {
         $menuItems = $scraperService->scrape($details['PageToScrape'], $details['CSSSelector']);
         if (count($menuItems) == 0) {
             continue;
         }
         MenuItem::get()->filter(array('MenuSet' => $menuSet))->removeAll();
         foreach ($menuItems as $menuItemData) {
             $menuItem = new MenuItem(array('MenuSet' => $menuSet, 'LinkText' => $menuItemData['html'], 'LinkHref' => $menuItemData['href']));
             $menuItem->write();
         }
     }
 }
開發者ID:helpfulrobot,項目名稱:deptinternalaffairsnz-silverstripe-navigation-scraper,代碼行數:19,代碼來源:MenuSetUpdateService.php

示例4: getMenuItem

 function getMenuItem()
 {
     $items = \MenuItem::get();
     foreach ($items as $item) {
         $item_price[] = $item->menu_item_price;
         $item_desc[] = $item->menu_item_short;
         $item_name[] = $item->menu_item_name;
         $item_fk[] = $item->menu_item_category_fk;
     }
     if (!isset($item)) {
         $items = null;
         return $items;
     }
     $items = array($item_name, $item_desc, $item_fk, $item_price);
     return $items;
 }
開發者ID:adamyWA,項目名稱:Menu-CMS,代碼行數:16,代碼來源:ShowMenu.php

示例5: getMenuItem

function getMenuItem($name, $menu)
{
    return MenuItem::get($name, $menu);
}
開發者ID:socialapparatus,項目名稱:socialapparatus,代碼行數:4,代碼來源:shortcuts.php

示例6: ScrapedMenu

 public static function ScrapedMenu($menuSetName)
 {
     return MenuItem::get()->filter(array('MenuSet' => $menuSetName));
 }
開發者ID:helpfulrobot,項目名稱:deptinternalaffairsnz-silverstripe-navigation-scraper,代碼行數:4,代碼來源:ScrapedMenuTemplateProvider.php


注:本文中的MenuItem::get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。