Skip to content

MenuEntry

Viames Marino edited this page Oct 19, 2026 · 2 revisions

Pair framework: MenuEntry

Pair\Html\MenuEntry is the final value object used by Menu renderers.

When to use

Use it indirectly through Menu/BootstrapMenu. In most applications you do not instantiate it manually.

Main behavior

  • Represents one node (label, URL, state, nesting metadata).
  • Serves as stable render input for menu classes.

Public fields

Field Default Purpose
type single Renderer branch: single, dropdown, separator, or title.
title '' Visible label.
url null Link URL.
icon null Font Awesome icon class.
badge null Optional badge text.
badgeType primary Badge tone.
target null Optional link target.
active false Active navigation state.
list [] Child MenuEntry objects for dropdown rendering.

These fields are mutable presentation state. Menu creates and populates entries internally; it does not expose a public getEntries() accessor or an API for appending an existing entry object.

Implementation examples

Through Menu

use Pair\Html\Menu;

$menu = new Menu();
$menu->item('dashboard/default', 'Dashboard', 'fa-house');
$menu->item('orders/default', 'Orders', 'fa-list');

echo $menu->render();

Through BootstrapMenu

use Pair\Html\BootstrapMenu;

$menu = new BootstrapMenu();
$menu->item('dashboard/default', 'Home', 'fa-house');
$menu->item('products/default', 'Products', 'fa-box');

echo $menu->render();

Common pitfalls

  • Persisting MenuEntry as business data; it is a rendering object with public mutable fields.
  • Passing title and URL in reverse order. item() takes the URL first and returns void, so it cannot be chained.

See also: Menu, BootstrapMenu, Breadcrumb.

Clone this wiki locally