PHP Class Devise\Menus\MenusRepository

Show file Open project: devisephp/cms

Public Methods

Method Description
__construct ( DvsMenu $Menu, DvsMenuItem $MenuItem, LanguageDetector $LanguageDetector, UserHelper $UserHelper, Framework $Framework )
buildMenu ( $name, integer $depth = 2, null $page = null ) : mixed Build a menu from it's name
findById ( $id ) : DvsMenu Finds DvsMenu by an integer id
findMenuByName ( string $name ) : array Find menu using name value
getChildrenMenuItems ( $name ) : array Get the children menu items of a menu name
getSiblingMenuItems ( $name ) : array Get menu siblings
menuStructure ( DvsMenu | DvsMenuItem $menu, boolean $isRootMenu = true ) : array A simple way to view the menu structure not in use by anything right now but here for troubleshooting menus if we need to
menus ( ) : Collection Returns a Collection of DvsMenus

Private Methods

Method Description
checkMenuItemPermission ( $permission ) : boolean Tells us whether or not the menu item is supposed to be shown to this user
childrenLoaded ( MenuItem $item ) : boolean checks if the children relation has been lazy loaded the goal is to respect the 'depth' value requested when the menu was built
getAllowedMenuItems ( DvsMenuItem $menuItem ) : DvsMenuItem | false This will let us know if the menu item is allowed and it also traverses all it's children (and future generations) filtering out menu items that are not allowed
getAllowedMenuItemsFromMenu ( DvsMenu $menu ) : Collection This gets us all the allowed menu items from a particular menu.
getLazyLoadByDepth ( $startingRelation, $depth ) : string generates the lazy load string based off the requested depth
getTranslation ( $menu ) : mixed Translate the menu if needed
locateCurrentMenuItem ( $pageId, $menuItems ) : boolean recursively traverses the menu items and their children finds the item that matches the current page, marks it as an 'activeItem' and marks it's parents as 'activeAncestor'
traverseMenu ( $menu, $depth, $page ) : mixed Traverses the menu recursively finding sub menus

Method Details

__construct() public method

public __construct ( DvsMenu $Menu, DvsMenuItem $MenuItem, LanguageDetector $LanguageDetector, UserHelper $UserHelper, Framework $Framework )
$Menu DvsMenu
$MenuItem DvsMenuItem
$LanguageDetector Devise\Languages\LanguageDetector
$UserHelper Devise\Users\UserHelper
$Framework Devise\Support\Framework

buildMenu() public method

Build a menu from it's name
public buildMenu ( $name, integer $depth = 2, null $page = null ) : mixed
$name
$depth integer
$page null
return mixed

findById() public method

Finds DvsMenu by an integer id
public findById ( $id ) : DvsMenu
$id
return DvsMenu

findMenuByName() public method

Find menu using name value
public findMenuByName ( string $name ) : array
$name string Human readable name of link
return array

getChildrenMenuItems() public method

Get the children menu items of a menu name
public getChildrenMenuItems ( $name ) : array
$name
return array

getSiblingMenuItems() public method

Get menu siblings
public getSiblingMenuItems ( $name ) : array
$name
return array

menuStructure() public method

A simple way to view the menu structure not in use by anything right now but here for troubleshooting menus if we need to
public menuStructure ( DvsMenu | DvsMenuItem $menu, boolean $isRootMenu = true ) : array
$menu DvsMenu | DvsMenuItem
$isRootMenu boolean
return array

menus() public method

Returns a Collection of DvsMenus
public menus ( ) : Collection
return Illuminate\Support\Collection