CMSMenu
class CMSMenu implements IteratorAggregate, i18nEntityProvider (View source)
The object manages the main CMS menu. See LeftAndMain::init() for example usage.
The menu will be automatically populated with menu items for subclasses of LeftAndMain. That is, for each class in the CMS that creates an administration panel, a CMS menu item will be created. The default configuration will also include a 'help' link to the SilverStripe user documentation.
Additional CMSMenu items can be added through LeftAndMainExtension::init() extensions added to LeftAndMain.
Constants
MENU_PRIORITY |
Sort by menu priority, highest to lowest |
URL_PRIORITY |
Sort by url priority, highest to lowest |
Properties
protected static | $menu_item_changes | An array of changes to be made to the menu items, in the order that the changes should be applied. Each item is a map in one of the two forms:
|
||
protected static | $menu_is_cleared | Set to true if clear_menu() is called, to indicate that the default menu shouldn't be included |
Methods
Generate CMS main menu items by collecting valid subclasses of LeftAndMain
Return a CMSMenuItem to add the given controller to the CMSMenu
Add an arbitrary URL to the CMS menu.
Add a navigation item to the main administration menu showing in the top bar.
Replace a navigation item to the main administration menu showing in the top bar.
Add a previously built menu item object to the menu
A utility funciton to retrieve subclasses of a given class that are instantiable (ie, not abstract) and have a valid menu title.
Details
static
populate_menu()
Generate CMS main menu items by collecting valid subclasses of LeftAndMain
static
add_controller(string $controllerClass)
Add a LeftAndMain controller to the CMS menu.
static protected CMSMenuItem
menuitem_for_controller(string $controllerClass)
Return a CMSMenuItem to add the given controller to the CMSMenu
static bool
add_link(string $code, string $menuTitle, string $url, int $priority = -1, array $attributes = null, string $iconClass = null)
Add an arbitrary URL to the CMS menu.
static bool
add_menu_item(string $code, string $menuTitle, string $url, string $controllerClass = null, int $priority = -1, array $attributes = null, string $iconClass = null)
Add a navigation item to the main administration menu showing in the top bar.
uses CMSMenu::$menu_items
static array
get_menu_item(string $code)
Get a single menu item by its code value.
static string
get_menu_code(string $cmsClass)
Get menu code for class
static array
get_menu_items()
Get all menu entries.
static CMSMenuItem[]
get_viewable_menu_items(Member $member = null)
Get all menu items that the passed member can view.
Defaults to Security::getCurrentUser().
static
remove_menu_item(string $code)
Removes an existing item from the menu.
static
remove_menu_class(string $className)
Remove menu item by class name.
static
clear_menu()
Clears the entire menu
static bool
replace_menu_item(string $code, string $menuTitle, string $url, string $controllerClass = null, int $priority = -1, array $attributes = null, string $iconClass = null)
Replace a navigation item to the main administration menu showing in the top bar.
static protected
add_menu_item_obj(string $code, CMSMenuItem $cmsMenuItem)
Add a previously built menu item object to the menu
static array
get_cms_classes(string $root = null, bool $recursive = true, string $sort = CMSMenu::MENU_PRIORITY)
A utility funciton to retrieve subclasses of a given class that are instantiable (ie, not abstract) and have a valid menu title.
Sorted by url_priority config.
Traversable
getIterator()
IteratorAggregate Interface Method. Iterates over the menu items.
array
provideI18nEntities()
Provide menu titles to the i18n entity provider