本文整理汇总了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