The menu node documents are only used for persisting the menu data, they are
not actually used when rendering a menu. The KnpMenu rendering engine needs
menu items. KnpMenu uses a factory to create the menu items from the menu
nodes provided by the menu provider. The menu factory can be customized with
extensions for additional functionality.
When menu nodes refer to content that has been deleted or there is another
error during route generation, that menu node (and its children) are ignored.
You can set cmf_menu.allow_empty_items to true to render these nodes as
plain text instead.
The CmfMenuBundle provides a MenuContentVoter, which checks if the
referenced content is published using the
publish workflow checker. If the content is
not yet published, the menu node (and its children) are ignored.
The CmfMenuBundle dispatches a cmf_menu.create_menu_item_from_node event
during the process of creating a menu item from a menu node. You can use this
event to control the MenuItem that is created and to mark the current node
or its children as skipped.
Listeners for this method receive a CreateMenuItemFromNodeEvent instance,
which provides access to node using the getNode() method and allows
skipping nodes using the setSkipNode() and setSkipChildren() methods.
If you mark the Menu document (the root node of each menu) as skipped,
an empty item is still created to avoid errors when rendering a menu.
You can use the setItem() method to set the menu item to use instead of the
one generated using the menu node. The child nodes are still processed like
normal and added to this new item.
You can inject the knp_menu.factory service in the listener to generate
new menu items from nodes.