|
| 1 | +.. index:: |
| 2 | + single: Menu; MenuAdmin |
| 3 | + |
| 4 | +Menu Admin with Sonata PHPCR-ODM |
| 5 | +================================ |
| 6 | + |
| 7 | +If the :doc:`SonataDoctrinePhpcrAdminBundle <../doctrine_phpcr_admin>` is |
| 8 | +loaded in the application kernel, menu node and menu documents can be |
| 9 | +administrated in Sonata admin. For instructions on how to configure Sonata, |
| 10 | +see :doc:`../doctrine_phpcr_admin`. |
| 11 | + |
| 12 | +Loading of Sonata is controlled with the ``use_sonata_admin`` configuration |
| 13 | +setting. By default, this option is automatically set based on whether |
| 14 | +SonataDoctrinePhpcrAdminBundle is available, but you can explicitly |
| 15 | +disable the flag to not provide the Sonata services even if Sonata would be |
| 16 | +available. You can also explicitly enable the flag to get an error if Sonata |
| 17 | +becomes unavailable. |
| 18 | + |
| 19 | +Sonata admin is using the ``content_basepath`` to show the tree of content to |
| 20 | +select the menu node target. |
| 21 | + |
| 22 | +.. configuration-block:: |
| 23 | + |
| 24 | + .. code-block:: yaml |
| 25 | +
|
| 26 | + # app/config/config.yml |
| 27 | + cmf_menu: |
| 28 | + dynamic: |
| 29 | + persistence: |
| 30 | + phpcr: |
| 31 | + # use true/false to force using / not using sonata admin |
| 32 | + use_sonata_admin: auto |
| 33 | +
|
| 34 | + # used with Sonata Admin to manage content; defaults to %cmf_core.basepath%/content |
| 35 | + content_basepath: ~ |
| 36 | +
|
| 37 | + .. code-block:: xml |
| 38 | +
|
| 39 | + <!-- app/config/config.xml --> |
| 40 | + <?xml version="1.0" encoding="UTF-8" ?> |
| 41 | + <container xmlns="http://cmf.symfony.com/schema/dic/services" |
| 42 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 43 | + xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> |
| 44 | +
|
| 45 | + <config xmlns="http://cmf.symfony.com/schema/dic/menu"> |
| 46 | + <dynamic> |
| 47 | + <persistence> |
| 48 | + <!-- use-sonata-admin: use true/false to force using / not using sonata admin --> |
| 49 | + <!-- content-basepath: used with Sonata Admin to manage content; |
| 50 | + defaults to %cmf_core.basepath%/content --> |
| 51 | + <phpcr |
| 52 | + use-sonata-admin="auto" |
| 53 | + content-basepath="null" |
| 54 | + /> |
| 55 | + </persistence> |
| 56 | + </dynamic> |
| 57 | + </config> |
| 58 | + </container> |
| 59 | +
|
| 60 | + .. code-block:: php |
| 61 | +
|
| 62 | + // app/config/config.php |
| 63 | + $container->loadFromExtension('cmf_menu', array( |
| 64 | + 'dynamic' => array( |
| 65 | + 'persistence' => array( |
| 66 | + 'phpcr' => array( |
| 67 | + // use true/false to force using / not using sonata admin |
| 68 | + 'use_sonata_admin' => 'auto', |
| 69 | +
|
| 70 | + // used with Sonata Admin to manage content; defaults to %cmf_core.basepath%/content |
| 71 | + 'content_basepath' => null, |
| 72 | + ), |
| 73 | + ), |
| 74 | + ), |
| 75 | + )); |
| 76 | +
|
| 77 | +
|
| 78 | +MenuNodeReferrersInterface Sonata Admin Extension |
| 79 | +------------------------------------------------- |
| 80 | + |
| 81 | +This bundle provides an extension to edit referring menu nodes for content that |
| 82 | +implements the ``MenuNodeReferrersInterface``. |
| 83 | + |
| 84 | +To enable the extensions in your admin classes, simply define the extension |
| 85 | +configuration in the ``sonata_admin`` section of your project configuration: |
| 86 | + |
| 87 | +.. configuration-block:: |
| 88 | + |
| 89 | + .. code-block:: yaml |
| 90 | +
|
| 91 | + # app/config/config.yml |
| 92 | + sonata_admin: |
| 93 | + # ... |
| 94 | + extensions: |
| 95 | + cmf_menu.admin_extension.menu_node_referrers: |
| 96 | + implements: |
| 97 | + - Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeReferrersInterface |
| 98 | +
|
| 99 | + .. code-block:: xml |
| 100 | +
|
| 101 | + <!-- app/config/config.xml --> |
| 102 | + <?xml version="1.0" encoding="UTF-8" ?> |
| 103 | + <container xmlns="http://cmf.symfony.com/schema/dic/services" |
| 104 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 105 | + xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> |
| 106 | +
|
| 107 | + <config xmlns="http://sonata-project.org/schema/dic/admin"> |
| 108 | + <!-- ... --> |
| 109 | + <extension id="cmf_menu.admin_extension.menu_node_referrers"> |
| 110 | + <implement>Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeReferrersInterface</implement> |
| 111 | + </extension> |
| 112 | + </config> |
| 113 | + </container> |
| 114 | +
|
| 115 | + .. code-block:: php |
| 116 | +
|
| 117 | + // app/config/config.php |
| 118 | + $container->loadFromExtension('sonata_admin', array( |
| 119 | + 'extensions' => array( |
| 120 | + 'cmf_menu.admin_extension.menu_node_referrers' => array( |
| 121 | + 'implements' => array( |
| 122 | + 'Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeReferrersInterface', |
| 123 | + ), |
| 124 | + ), |
| 125 | + ), |
| 126 | + )); |
| 127 | +
|
| 128 | +See the `Sonata Admin extension documentation`_ for more information. |
| 129 | + |
| 130 | +.. _`Sonata Admin extension documentation`: http://sonata-project.org/bundles/admin/master/doc/reference/extensions.html |
0 commit comments