本文整理匯總了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);
}
}
}
}
示例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;
}
示例5: getMenuItem
function getMenuItem($name, $menu)
{
return MenuItem::get($name, $menu);
}
示例6: ScrapedMenu
public static function ScrapedMenu($menuSetName)
{
return MenuItem::get()->filter(array('MenuSet' => $menuSetName));
}
開發者ID:helpfulrobot,項目名稱:deptinternalaffairsnz-silverstripe-navigation-scraper,代碼行數:4,代碼來源:ScrapedMenuTemplateProvider.php