Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 8972e37

Browse files
committed
Merge pull request #699 from symfony-cmf/menu-allow-empty
document menu configuration options
2 parents 577abd9 + 2f9109c commit 8972e37

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

bundles/menu/configuration.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ admin_recursive_breadcrumbs
180180
When editing a node, this setting will cause the Sonata admin breadcrumb to
181181
include ancestors of the node being edited.
182182

183+
content_url_generator
184+
~~~~~~~~~~~~~~~~~~~~~
185+
186+
.. versionadded:: 1.2
187+
This option was introduced in version 1.2.0. Prior to 1.2, this option is
188+
not available and the default service ``router`` is hardcoded.
189+
190+
**type**: ``string`` **default**: ``router``
191+
192+
With this option, you can change what router should be used for generating
193+
URLs from menu nodes of type "content".
194+
195+
allow_empty_items
196+
~~~~~~~~~~~~~~~~~
197+
198+
**type**: ``boolean`` **default**: ``false``
199+
200+
Whether menu nodes without URL should be hidden or rendered as text without a
201+
link.
202+
183203
Admin Extensions
184204
----------------
185205

bundles/menu/menu_factory.rst

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ A menu item should have a URL associated with it. The CMF provides the
2626
from the ``content`` and ``routeParameters`` options when using the
2727
:ref:`dynamic router <bundles-routing-dynamic-generator>`.
2828

29-
The ``content`` option, if specified, must contain a class which implements
30-
the ``RouteReferrersInterface``, see the :ref:`dynamic router
31-
<bundles-routing-dynamic-generator>` documentation for more information.
29+
The ``content`` option, if specified, must contain something that the content
30+
URL generator can work with. When using the :ref:`dynamic router
31+
<bundles-routing-dynamic-generator>`, this needs to be a class implementing
32+
the ``RouteReferrersInterface``. You can alternatively specify a custom
33+
``UrlGeneratorInterface`` with the ``content_url_generator`` configuration
34+
option.
35+
36+
.. versionadded:: 1.2
37+
The ``content_url_generator`` option was introduced in CmfMenuBundle 1.2.0.
38+
Prior to 1.2, the default service ``router`` was hardcoded to generate URLs
39+
from content.
3240

3341
URL generation is absolute or relative, depending on the boolean value of the
3442
``routeAbsolute`` option.
@@ -44,14 +52,24 @@ of the three URL generation techniques to use.
4452
The values for this options can be one of the following:
4553

4654
* ``null``: If the value is ``null`` (or the options is not set) then the link
47-
type is determined automatically by looking at each of the ``uri``, ``route`` and
48-
``content`` options and using the first one which is non-null.
55+
type is determined automatically by looking at each of the ``uri``, ``route``
56+
and ``content`` options and using the first one which is non-null.
4957
* **uri**: Use the URI provided by the ``uri`` option.
5058
* **route**: Generate a URL using the route named by the ``route`` option
5159
and the parameters provided by the ``routeParameters`` option.
52-
* **content**: Generate a URL by passing the ``RouteReferrersInterface``
53-
instance provided by the ``content`` option to the router using any
54-
parameters provided by the ``routeParameters`` option.
60+
* **content**: Generate a URL by passing the value of the ``content`` option to
61+
the content URL generator, using any parameters provided by the
62+
``routeParameters`` option.
63+
64+
Menu Nodes without URL
65+
~~~~~~~~~~~~~~~~~~~~~~
66+
67+
A menu node document might not have a URL, when that information was never set
68+
or it points to a content that has been deleted meanwhile. In that case, there
69+
are two options: The menu node can be skipped, or it can be rendered as text
70+
without link. By default, the node is skipped.
71+
72+
You can set ``cmf_menu.allow_empty_items`` to true to render nodes without URL.
5573

5674
Publish Workflow
5775
----------------
@@ -61,7 +79,7 @@ visible by use of the :doc:`publish workflow checker
6179
<../core/publish_workflow>`.
6280

6381
.. versionadded:: 1.1
64-
The ``MenuContentVoter`` was added in CmfMenuBundle 1.1.
82+
The ``MenuContentVoter`` was introduced in CmfMenuBundle 1.1.
6583

6684
The ``MenuContentVoter`` decides that a menu node is not published if the
6785
content it is pointing to is not published.

0 commit comments

Comments
 (0)