Class dmitrybtn\yimp\MenuAdapter
Inheritance | dmitrybtn\yimp\MenuAdapter » yii\base\BaseObject |
---|
Adapter for yii\bootstrap4\Nav, providing some additional functionality.
The following functionality is provided:
- Configure items visibility for desktops and mobiles separately.
- Generate an empty string if menu is invisible. Menu is invisible on current device if all link items are invisible on this device, even if there are visible labels (items with empty 'url' property).
Config array, passed to dmitrybtn\yimp\MenuAdapter::widget() differs from the original in the following:
mode
: YIMP renders each menu in layout two times - for desktops and for mobile devices. In first case it sets this prop to dmitrybtn\yimp\Yimp::DESKTOP, in second - to dmitrybtn\yimp\Yimp::MOBILE. If item'svisibleMode
prop is set, this item will be rendered only if it'svisibleMode
value equals to this one.items
:active
: In original widget it is bool. Here it can be string, representing the mask, passed to dmitrybtn\yimp\RouteHelper::match(). If current route matches this mask, item will be activated. For example, this property is set toorders/*
, item will be active onorders/create
,orders/update
,orders/item/create
, and so on.visibleMode
: If you want to show menu item only on desktops, set it toYimp::DESKTOP
. For mobiles -YIMP::MOBILE
.
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$mode | string | Mode for display menu. | dmitrybtn\yimp\MenuAdapter |
$route | string | Current route | dmitrybtn\yimp\MenuAdapter |
$visible | boolean | Whether all menu is visible | dmitrybtn\yimp\MenuAdapter |
Public Methods
Method | Description | Defined By |
---|---|---|
widget() | Creates Bootstrap Nav widget instance and renders it. | dmitrybtn\yimp\MenuAdapter |
Protected Methods
Method | Description | Defined By |
---|---|---|
adapt() | Adapts menu items to Bootstrap Nav widget format. | dmitrybtn\yimp\MenuAdapter |
adaptItem() | Adapts menu item to Bootstrap Nav widget format. | dmitrybtn\yimp\MenuAdapter |
Property Details
Mode for display menu. Can be Yimp::DESKTOP or Yimp::MOBILE
Current route
Whether all menu is visible
Method Details
Adapts menu items to Bootstrap Nav widget format.
protected array adapt ( $items ) | ||
$items | Array List of menu items |
|
return | array | List of adapted menu items |
---|
Adapts menu item to Bootstrap Nav widget format.
protected array adaptItem ( $item ) | ||
$item | Array Menu item config |
|
return | array | Adapted menu item config |
---|
Creates Bootstrap Nav widget instance and renders it.
public string widget ( $config = [] ) | ||
$config | array | Config array to be adapted for Bootstrap Nav widget. |
throws | Exception |
---|