All notable changes to menu will be documented in this file.
- Support PHP 8+
- Drop support for PHP 7.x
- Use PHP 8 syntax where possible
- Ensure
Itemsare transformed to string before prepending or appending
- Fix
methods_existscheck in PHP8
- Ensure the necessary methods exist to check if a menu is active
- Support
Iteminstances inMenu::prependso headers can be set active
- Drop support for versions older than PHP 7.1
- Add
exact-activeclass to links that exactly match the current URL. This is accompanied by asetExactActiveClass(string $class)method to set the class name
- Add
IteratorAggregateinterface toMenuclass
- Add
beforeRenderandwillRenderhooks that are called when an item is rendered
- This release adds a few methods to create non-
ulmenus, which allows for Bootstrap 4 compatibility - Added
Menu::setWrapperTagandMenu::withoutWrapperTagto set a custom wrapper tag name for the menu list. Default:ul - Added
Menu::setParentTag&Menu::withoutParentTagto determine which tag should be used for the item's parent element. Default:li - Added
Menu::setActiveClassOnLinkandMenu::setActiveClassOnParentto determine where the active class should be applied
- Allow invokable classes as callbacks
- Added
Menu::emptyandHtml::emptymethod for adding empty list items
- Extracted a
ActiveUrlCheckerclass for public use
- Added
appendandprependmethods toLink
- Fixed returning a menu instance is now optional with
fillandbuild
- Fixed setting items active with urls that start with the same string
- Added
iffunction
- Fixed setting an active url when the url is exactly the same
- Added the request root path when setting the active path
- Added optional third
$initialparameter inMenu::build
- Fixed require
^1.0.0of spatie/url
- Added added the static
Menu::buildand non-staticMenu::fillmethods to create menu's from arrays. - Added the
setActivemethod onActivatablenow also accepts a non-strict boolean or callable parameter to set$activeto true or false. - Added
Menu::htmlandMenu::htmlIfnow accept a$parentAttributesarray as their second arguments. - Changed the
HtmlAttributesandParentAttributestraits have been renamed toHasHtmlAttributesandHasParentAttributes. - Changed the
HasUrlinterface and trait has been removed. Url-related methods now also are part of theActivatableinterface and trait. - Removed the
voidandvoidIfhave been removed. These can be replaced byhtmlandhtmlIf, with empty strings as their first arguments - Removed the
prefixLinksandprefixUrlsmethods have been removed because they were too unpredictable in some case. There currently isn't an alternative for these, besides writing your own logic and applying it withapplyToAll.
- Added a
HasUrltrait - Deprecated
prefixLinksin favor ofprefixUrls
- Added
submenuIf
- Internal refactors
- New methods on
Menu:submenufor submenus with optional headersvoidandvoidIffor empty list itemswrapto wrap the menu in an html tag with optional attributes- A
blueprintmethod to copy the menu without it's contents - Html item convenience methods:
addItemClass,setItemAttribute - Html parent convenience methods:
addItemParentClass,setItemParentAttribute
- Added
HasHtmlAttributesandHasParentAttributesinterfaces HtmlAttributesandParentAttributesnow also have asetAttributesmethod
- Fixed
setActivewhen setting active from a URL
- Added conditional
addfunctions,addIf,linkIfandhtmlIf
- First release