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

Commit 7930944

Browse files
committed
update menu bundle documentation for cmf 2.0
1 parent b10f811 commit 7930944

File tree

12 files changed

+386
-446
lines changed

12 files changed

+386
-446
lines changed

bundles/map.rst.inc

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ library or they introduce a complete new concept.
2929
* :doc:`menu/menu_factory`
3030
* :doc:`menu/menu_provider`
3131
* :doc:`menu/voters`
32-
* :doc:`menu/sonata_admin`
3332
* :doc:`menu/configuration`
3433

3534
* :doc:`routing/index`

bundles/menu/configuration.rst

+12-116
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ persistence configuration has the following configuration:
2626
phpcr:
2727
enabled: false
2828
menu_basepath: /cms/menu
29-
content_basepath: ~
30-
prefetch: 10
29+
content_basepath: /cms/content
3130
manager_name: ~
31+
prefetch: 10
3232
menu_document_class: Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu
3333
node_document_class: Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode
34-
use_sonata_admin: ~
35-
menu_admin_class: Symfony\Cmf\Bundle\MenuBundle\Admin\MenuAdmin
36-
node_admin_class: Symfony\Cmf\Bundle\MenuBundle\Admin\MenuNodeAdmin
37-
admin_recursive_breadcrumbs: true
38-
3934
4035
.. code-block:: xml
4136
@@ -47,15 +42,11 @@ persistence configuration has the following configuration:
4742
<phpcr
4843
enabled="false"
4944
menu-basepath="/cms/menu"
50-
content-basepath="null"
51-
prefetch="10"
45+
content-basepath="/cms/content"
5246
manager-name="null"
53-
menu-document-class="null"
54-
node-document-class="null"
55-
use-sonata-admin="auto"
56-
menu-admin-class="null"
57-
node-admin-class="null"
58-
admin-recursive-breadcrumbs="true"
47+
prefetch="10"
48+
menu-document-class="Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu"
49+
node-document-class="Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode"
5950
/>
6051
</persistence>
6152
</config>
@@ -69,15 +60,11 @@ persistence configuration has the following configuration:
6960
'phpcr' => [
7061
'enabled' => false,
7162
'menu_basepath' => '/cms/menu',
72-
'content_basepath' => null,
73-
'prefetch' => 10,
63+
'content_basepath' => '/cms/content',
7464
'manager_name' => null,
75-
'menu_document_class' => null,
76-
'node_document_class' => null,
77-
'use_sonata_admin' => 'auto',
78-
'menu_admin_class' => null,
79-
'node_admin_class' => null,
80-
'admin_recursive_breadcrumbs' => true,
65+
'prefetch' => 10,
66+
'menu_document_class' => \Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu::class,
67+
'node_document_class' => \Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode::class,
8168
],
8269
],
8370
]);
@@ -109,8 +96,8 @@ the value of ``%cmf_core.persistence.phpcr.basepath%/menu``
10996
**type**: ``string`` **default**: ``/cms/content``
11097

11198
Specifies the path in the PHPCR-ODM document hierarchy under which the
112-
content documents can be found. This is used by the admin class to pre-select
113-
the content branch of the document hierarchy in forms.
99+
content documents can be found. This is used by the sonata admin integration to
100+
know which subtree to show when selecting content for menu nodes.
114101

115102
If the :doc:`CoreBundle <../core/introduction>` is registered, this will default to
116103
the value of ``%cmf_core.persistence.phpcr.basepath%/content``
@@ -156,33 +143,6 @@ Specifies the document class which should represent a single menu node.
156143

157144
This setting is used by the admin class.
158145

159-
``use_sonata_admin``
160-
""""""""""""""""""""
161-
162-
.. include:: ../_partials/persistence_phpcr_sonata_admin_enabled.rst.inc
163-
164-
``menu_admin_class``
165-
""""""""""""""""""""
166-
167-
**type**: ``string`` **default**: ``Symfony\Cmf\Bundle\MenuBundle\Admin\MenuAdmin``
168-
169-
The Sonata admin class to use for the menu.
170-
171-
``node_admin_class``
172-
""""""""""""""""""""
173-
174-
**type**: ``string`` **default**: ``Symfony\Cmf\Bundle\MenuBundle\Admin\MenuNodeAdmin``
175-
176-
The Sonata admin class to use for the menu node.
177-
178-
``admin_recursive_breadcrumbs``
179-
"""""""""""""""""""""""""""""""
180-
181-
**type**: ``boolean`` **default**: ``true``
182-
183-
When editing a node, this setting will cause the Sonata admin breadcrumb to
184-
include ancestors of the node being edited.
185-
186146
content_url_generator
187147
~~~~~~~~~~~~~~~~~~~~~
188148

@@ -203,70 +163,6 @@ allow_empty_items
203163
Whether menu nodes without URL should be hidden or rendered as text without a
204164
link.
205165

206-
Admin Extensions
207-
----------------
208-
209-
The ``admin_extensions`` section contains the configurations of the admin extensions that comes with the menu bundle.
210-
211-
``menu_options``
212-
~~~~~~~~~~~~~~~~
213-
214-
You can configure the menu options extension in this sections.
215-
216-
.. configuration-block::
217-
218-
.. code-block:: yaml
219-
220-
# app/config/config.yml
221-
cmf_menu:
222-
# ...
223-
cmf_menu:
224-
admin_extensions:
225-
menu_options:
226-
enabled: auto
227-
advanced: false
228-
229-
.. code-block:: xml
230-
231-
<!-- app/config/config.xml -->
232-
<?xml version="1.0" charset="UTF-8" ?>
233-
<container xmlns="http://symfony.com/schema/dic/services">
234-
<config xmlns="http://cmf.symfony.com/schema/dic/menu">
235-
<admin_extensions>
236-
<menu_options
237-
enabled="auto"
238-
advanced="false"
239-
/>
240-
</admin_extensions>
241-
</config>
242-
</container>
243-
244-
.. code-block:: php
245-
246-
// app/config/config.php
247-
$container->loadFromExtension('cmf_menu', [
248-
'admin_extensions' => [
249-
'menu_options' => [
250-
'enabled' => 'auto',
251-
'advanced' => false,
252-
],
253-
],
254-
]);
255-
256-
``enabled``
257-
"""""""""""
258-
**type**: ``enum`` **valid values**: ``true|false|auto`` **default**: ``auto``
259-
260-
If ``true``, the admin extension is activated. If set to ``auto``, it will be
261-
activated only if the SonataAdminBundle is present.
262-
263-
``advanced``
264-
""""""""""""
265-
**type**: ``boolean`` **default**: ``false``
266-
267-
if set to ``true`` it will expose the advanced options in the admin.
268-
To enable this options you need ``BurgovKeyValueFormBundle``
269-
270166
Voter
271167
-----
272168

bundles/menu/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ MenuBundle
99
menu_factory
1010
menu_provider
1111
voters
12-
sonata_admin
1312
configuration

bundles/menu/introduction.rst

+20-23
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ features:
1111
* Render menus stored in the persistence layer;
1212
* Generate menu node URLs from linked Content or Route.
1313

14-
Note that only the Doctrine PHPCR-ODM persistence layer is currently supported.
14+
Note that this bundle currently only provides models for the Doctrine PHPCR-ODM
15+
persistence layer.
1516

1617
.. caution::
1718

1819
Make sure you understand how the `KnpMenuBundle`_ works when you want to
1920
customize the CmfMenuBundle. The CMF menu bundle is just adding
20-
functionality on top of the Knp menu bundle and this documentation is
21-
focused on the additional functionality.
21+
functionality on top of KnpMenuBundle and this documentation is focused on
22+
the additional functionality.
2223

2324
Installation
2425
------------
@@ -27,7 +28,7 @@ You can install this bundle `with composer`_ using the
2728
`symfony-cmf/menu-bundle`_ package.
2829

2930
As the bundle is using the `KnpMenuBundle`_, you need to instantiate that
30-
bundles in addition to the CmfMenuBundle::
31+
bundle in addition to the CmfMenuBundle::
3132

3233
// app/AppKernel.php
3334

@@ -51,19 +52,17 @@ bundles in addition to the CmfMenuBundle::
5152
Creating a Simple Persistent Menu
5253
---------------------------------
5354

54-
A menu created using the KnpMenuBundle is made up of a hierarchy of class
55-
instances implementing ``NodeInterface``. This is also true of a menu created
56-
using MenuBundle documents.
55+
For KnpMenu_, a menu is made up of a hierarchy of objects implementing
56+
``ItemInterface``. KnpMenu provides the concept of factories to create menus
57+
from ``NodeInterface``. This bundle contains a provider to load menu nodes from
58+
PHPCR.
5759

58-
It is recommended that the root document of the menu tree is a ``Menu``
59-
document, all descendant documents should be ``MenuNode`` instances.
60+
The root document of each menu tree is a ``Menu`` document, all descendant
61+
documents should be ``MenuNode`` instances. The menu roots are placed under the
62+
``cmf_menu.persistence.phpcr.menu_basepath``, which defaults to ``/cms/menu``.
6063

61-
The root document should be a child of the document specified in the configuration
62-
by the parameter ``persistence.phpcr.menu_basepath``, which defaults to ``/cms/menu``. Note
63-
that if this document does not exist it must be created.
64-
65-
The example below creates a new menu with two items, "Home" and "Contact",
66-
each of which specifies a URI::
64+
The example below creates a new menu called "Main Menu" with two nodes, "Home"
65+
and "Contact", each of which specifies a URI::
6766

6867
use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode;
6968
use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu;
@@ -99,8 +98,8 @@ each of which specifies a URI::
9998

10099
.. note::
101100

102-
When the bundle is registered, it will create the ``/cms/menu`` path
103-
when executing ``doctrine:phpcr:repository:init``. For more information,
101+
When the bundle is registered, it will create the ``menu_basepath`` as part
102+
of the ``doctrine:phpcr:repository:init`` command. For more information,
104103
see :ref:`Repository Initializers <phpcr-odm-repository-initializers>`
105104

106105
Rendering Menus
@@ -136,9 +135,8 @@ will render an unordered list as follows:
136135

137136
.. tip::
138137

139-
Sometimes, the menu is not located within the ``persistence.phpcr.menu_basepath``.
140-
In this case, you can use an absolute path (starting with a forward slash) to render
141-
the menu:
138+
To render a menu that is not a child of the ``menu_basepath``, you can use
139+
an absolute path (starting with a forward slash):
142140

143141
.. configuration-block::
144142

@@ -165,9 +163,9 @@ will render an unordered list as follows:
165163
.. caution::
166164

167165
If you want to render the menu from Twig, make sure you have not disabled
168-
Twig in the ``knp_menu`` configuration section.
166+
the Twig integration in the ``knp_menu`` configuration section.
169167

170-
For more information see the `rendering menus`_ section of the KnpMenuBundle documentation.
168+
For more information, see the `rendering menus`_ section of the KnpMenuBundle documentation.
171169

172170
Read On
173171
-------
@@ -176,7 +174,6 @@ Read On
176174
* :doc:`menu_factory`
177175
* :doc:`menu_provider`
178176
* :doc:`voters`
179-
* :doc:`sonata_admin`
180177
* :doc:`configuration`
181178

182179
.. _`KnpMenu`: https://github.com/knplabs/KnpMenu

bundles/menu/menu_documents.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ the KnpMenu component documentation for more information.
1919

2020
.. code-block:: php
2121
22+
use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu;
2223
use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNodeBase;
2324
2425
// find the menu tree root
25-
$mainMenu = $dm->find('Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu', '/cms/menu/main');
26+
$mainMenu = $dm->find(Menu::class, '/cms/menu/main');
2627
2728
$node = new MenuNodeBase();
2829
$mainMenu->addChild($node);
@@ -83,7 +84,7 @@ content document from which the URL can be generated::
8384
The content document can be any document which implements the
8485
``RouteReferrersInterface``. See :ref:`bundles-routing-dynamic-generator`.
8586

86-
This content document will then be passed to the ``ContentAwareFactory`` see
87+
This content document will then be handled by the ``ContentExtension``, see
8788
:ref:`URL Generation <bundles_menu_menu_factory_url_generation>` for more details.
8889

8990
Link Type Specification
@@ -101,8 +102,8 @@ more information.
101102
Translation
102103
~~~~~~~~~~~
103104

104-
The standard menu node supports translation when it is enabled, allowing the
105-
locale to be set via. the ``setLocale`` method::
105+
The standard menu node supports translation if enabled, allowing the
106+
locale to be set via the ``setLocale`` method::
106107

107108
$menuItem = ...;
108109
$menuItem->setLocale('fr');

bundles/menu/menu_factory.rst

+17-16
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
Menu Factory
55
============
66

7-
The menu documents are only used for persisting the menu data, they are not
8-
actually used when rendering a menu. Menu items are the objects that are needed
9-
to render a menu. A menu factory creates such *menu items* from the *menu
10-
nodes* provided by the menu provider.
7+
The menu node documents are only used for persisting the menu data, they are
8+
not actually used when rendering a menu. The KnpMenu rendering engine needs
9+
menu items. KnpMenu uses a factory to create the *menu items* from the *menu
10+
nodes* provided by the menu provider. The menu factory can be customized with
11+
extensions for additional functionality.
1112

1213
.. _bundles_menu_menu_factory_url_generation:
1314

@@ -28,7 +29,7 @@ from content objects.
2829

2930
The ``content`` menu node option, if specified, must contain something that the
3031
content URL generator can work with. When using the :ref:`dynamic router
31-
<bundles-routing-dynamic-generator>`, this needs to be a class implementing the
32+
<bundles-routing-dynamic-generator>`, this means an instance of
3233
``RouteReferrersInterface``.
3334

3435
.. tip::
@@ -40,21 +41,21 @@ content URL generator can work with. When using the :ref:`dynamic router
4041
.. versionadded:: 1.2
4142
The ``content_url_generator`` option was introduced in CmfMenuBundle 1.2.
4243

43-
How to handle Items without a URL
44-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44+
How to handle Items without an URL
45+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4546

4647
When menu nodes refer to content that has been deleted or there is another
47-
error during route generation, a menu node is skipped by default. You can set
48-
the ``allow_empty_items`` setting of the CmfMenuBundle to ``true`` to render
49-
these nodes as plain text instead.
48+
error during route generation, that menu node (and its children) are ignored.
49+
You can set ``cmf_menu.allow_empty_items`` to ``true`` to render these nodes as
50+
plain text instead.
5051

5152
.. _bundles_menu_menu_factory_link_type:
5253

5354
Specifying the Link Type
5455
~~~~~~~~~~~~~~~~~~~~~~~~
5556

56-
The CMF provides a ``linkType`` option, which enables you to specify which URL
57-
generation technique (URI, route or content) should be used.
57+
The menu nodes has a ``linkType`` option, which enables you to specify which
58+
URL generation technique (URI, route or content) should be used.
5859

5960
The values for this options can be one of the following:
6061

@@ -81,7 +82,7 @@ Publish Workflow
8182
The CmfMenuBundle provides a ``MenuContentVoter``, which checks if the
8283
referenced content is published using the
8384
:doc:`publish workflow checker <../core/publish_workflow>`. If the content is
84-
not yet published, the menu item not will not be rendered.
85+
not yet published, the menu node (and its children) are ignored.
8586

8687
Customizing Menus using Events
8788
------------------------------
@@ -100,9 +101,9 @@ skipping nodes using the ``setSkipNode()`` and ``setSkipChildren()`` methods.
100101
If you mark the ``Menu`` document (the root node of each menu) as skipped,
101102
an empty item is still created to avoid errors when rendering a menu.
102103

103-
You can use the ``setItem()`` method to set the menu item to use instead of one
104-
generated using the menu node. The child nodes are still processed like normal
105-
and added to this new item.
104+
You can use the ``setItem()`` method to set the menu item to use instead of the
105+
one generated using the menu node. The child nodes are still processed like
106+
normal and added to this new item.
106107

107108
.. tip::
108109

0 commit comments

Comments
 (0)