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

Commit 7ef9ca5

Browse files
committed
Merge pull request #548 from symfony-cmf/mkoosej-menu-options
Document MenuOptionsInterface and sonata admin extension
2 parents fee4726 + a0de4a3 commit 7ef9ca5

File tree

3 files changed

+177
-1
lines changed

3 files changed

+177
-1
lines changed

bundles/menu/sonata_admin.rst

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,114 @@ configuration in the ``sonata_admin`` section of your project configuration:
121121
122122
See the `Sonata Admin extension documentation`_ for more information.
123123

124+
MenuOptionInterface Sonata Admin Extension
125+
------------------------------------------
126+
127+
This bundle provides an extension that allows user to edit different menu
128+
options using the Sonata admin interface.
129+
130+
To enable the extensions in your admin classes, simply define the extension
131+
configuration in the ``sonata_admin`` section of your project configuration:
132+
133+
.. configuration-block::
134+
135+
.. code-block:: yaml
136+
137+
# app/config/config.yml
138+
sonata_admin:
139+
# ...
140+
extensions:
141+
cmf_menu.admin_extension.menu_options:
142+
implements:
143+
- Symfony\Cmf\Bundle\MenuBundle\Model\MenuOptionsInterface
144+
145+
.. code-block:: xml
146+
147+
<!-- app/config/config.xml -->
148+
<?xml version="1.0" encoding="UTF-8" ?>
149+
<container xmlns="http://cmf.symfony.com/schema/dic/services"
150+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
151+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
152+
153+
<config xmlns="http://sonata-project.org/schema/dic/admin">
154+
<!-- ... -->
155+
<extension id="cmf_menu.admin_extension.menu_options">
156+
<implement>Symfony\Cmf\Bundle\MenuBundle\Model\MenuOptionsInterface</implement>
157+
</extension>
158+
</config>
159+
</container>
160+
161+
.. code-block:: php
162+
163+
// app/config/config.php
164+
$container->loadFromExtension('sonata_admin', array(
165+
'extensions' => array(
166+
'cmf_menu.admin_extension.menu_options' => array(
167+
'implements' => array(
168+
'Symfony\Cmf\Bundle\MenuBundle\Model\MenuOptionsInterface',
169+
),
170+
),
171+
),
172+
));
173+
174+
See the `Sonata Admin extension documentation`_ for more information.
175+
176+
These are the list of available options:
177+
178+
* Display;
179+
* Display children;
180+
* Menu attributes (advanced);
181+
* Label attributes (advanced);
182+
* Children attributes (advanced);
183+
* Link attributes (advanced).
184+
185+
See the `KnpMenuBundle documentation`_ for more information about these
186+
attributes.
187+
188+
By default the only available options are **Display** and **Display Children**.
189+
To enable the advaned options you need to add ``burgov/key-value-form-bundle``
190+
requirement in your ``composer.json`` and enable the advanced options in
191+
your config file:
192+
193+
.. configuration-block::
194+
195+
.. code-block:: yaml
196+
197+
# app/config/config.yml
198+
cmf_menu:
199+
admin_extensions:
200+
menu_options:
201+
advanced: true
202+
203+
204+
.. code-block:: xml
205+
206+
<!-- app/config/config.xml -->
207+
<?xml version="1.0" encoding="UTF-8" ?>
208+
<container xmlns="http://cmf.symfony.com/schema/dic/services"
209+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
210+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
211+
212+
<config xmlns="http://cmf.symfony.com/schema/dic/menu">
213+
<admin-extensions>
214+
<menu-options advanced="true">
215+
</admin-extensions>
216+
</config>
217+
218+
</container>
219+
220+
.. code-block:: php
221+
222+
// app/config/config.php
223+
$container->loadFromExtension('cmf_menu', array(
224+
'admin_extensions' => array(
225+
'menu_options' => array(
226+
'advanced' => true,
227+
),
228+
),
229+
));
230+
124231
.. _`Sonata Admin extension documentation`: http://sonata-project.org/bundles/admin/master/doc/reference/extensions.html
125232
.. _SonataDoctrinePHPCRAdminBundle: http://sonata-project.org/bundles/doctrine-phpcr-admin/master/doc/index.html
126233
.. _`configuring sonata admin`: http://sonata-project.org/bundles/doctrine-phpcr-admin/master/doc/reference/configuration.html
234+
.. _`KnpMenuBundle documentation`: http://github.com/KnpLabs/KnpMenu/blob/master/doc/01-Basic-Menus.markdown#menu-attributes

bundles/simple_cms/menus.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Menus
55
-----
66

7-
You can use `Knp Menu Bundle`_ to render a menu of your SimpleCms pages. The default Page document
7+
You can use `Knp Menu Bundle`_ to render a menu of your SimpleCms pages. The default Page document
88
(``Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page``) implements the ``Knp\Menu\NodeInterface``
99
which allows for rendering them as a menu.
1010

@@ -41,4 +41,10 @@ setDisplay($display)
4141
setDisplayChildren($displayChildren)
4242
Boolean which determines whether children should be added to the menu
4343

44+
.. tip::
45+
46+
If you use Sonata Admin in your project you can edit the menu options
47+
using the MenuOptionsExtension that comes with the menu bundle. For more
48+
information on how to use it take a look at the :doc:`menu bundle documentation <../menu/sonata_admin>`
49+
4450
.. _`Knp Menu Bundle`: https://github.com/KnpLabs/KnpMenuBundle

reference/configuration/menu.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,68 @@ admin_recursive_breadcrumbs
180180

181181
When editing a node, this setting will cause the Sonata admin breadcrumb to include ancestors of the node being edited.
182182

183+
Admin Extensions
184+
----------------
185+
186+
The ``admin_extensions`` section contains the configurations of the admin extensions that comes with the menu bundle.
187+
188+
menu_options
189+
~~~~~~~~~~~~
190+
191+
You can configure the menu options extension in this sections.
192+
193+
.. configuration-block::
194+
195+
.. code-block:: yaml
196+
197+
cmf_menu:
198+
# ...
199+
cmf_menu:
200+
admin_extensions:
201+
menu_options:
202+
enabled: auto
203+
advanced: false
204+
205+
.. code-block:: xml
206+
207+
<?xml version="1.0" charset="UTF-8" ?>
208+
<container xmlns="http://symfony.com/schema/dic/services">
209+
<config xmlns="http://cmf.symfony.com/schema/dic/menu">
210+
<admin_extensions>
211+
<menu_options
212+
enabled="auto"
213+
advanced="false"
214+
/>
215+
</admin_extensions>
216+
</config>
217+
</container>
218+
219+
.. code-block:: php
220+
221+
$container->loadFromExtension('cmf_menu', array(
222+
'admin_extensions' => array(
223+
'menu_options' => array(
224+
'enabled' => 'auto',
225+
'advanced' => false,
226+
),
227+
),
228+
),
229+
));
230+
231+
enabled
232+
"""""""
233+
**type**: ``enum`` **valid values**: ``true|false|auto`` **default**: ``auto``
234+
235+
If ``true``, the admin extension is activated. If set to ``auto``, it will be
236+
activated only if the SonataAdminBundle is present.
237+
238+
advanced
239+
""""""""
240+
**type**: ``boolean`` **default**: ``false``
241+
242+
if set to ``true`` it will expose the advanced options in the admin.
243+
To enable this options you need ``BurgovKeyValueFormBundle``
244+
183245
Voter
184246
-----
185247

0 commit comments

Comments
 (0)