English spoken conference

Configuration Reference

1.3 version
Maintained Unmaintained
1.2

Configuration Reference

The MenuBundle can be configured under the cmf_menu key in your application configuration. When using XML you should use the http://cmf.symfony.com/schema/dic/menu namespace.

Configuration

persistence

This defines the persistence driver and associated classes. The default persistence configuration has the following configuration:

  • YAML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    # app/config/config.yml
    cmf_menu:
        persistence:
            phpcr:
                enabled:                     false
                menu_basepath:               /cms/menu
                content_basepath:            ~
                prefetch:                    10
                manager_name:                ~
                menu_document_class:         Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu
                node_document_class:         Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode
                use_sonata_admin:            ~
                menu_admin_class:            Symfony\Cmf\Bundle\MenuBundle\Admin\MenuAdmin
                node_admin_class:            Symfony\Cmf\Bundle\MenuBundle\Admin\MenuNodeAdmin
                admin_recursive_breadcrumbs: true
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <!-- app/config/config.xml -->
    <?xml version="1.0" charset="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
        <config xmlns="http://cmf.symfony.com/schema/dic/menu">
            <persistence>
                <phpcr
                    enabled="false"
                    menu-basepath="/cms/menu"
                    content-basepath="null"
                    prefetch="10"
                    manager-name="null"
                    menu-document-class="null"
                    node-document-class="null"
                    use-sonata-admin="auto"
                    menu-admin-class="null"
                    node-admin-class="null"
                    admin-recursive-breadcrumbs="true"
                />
            </persistence>
        </config>
    </container>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    //  app/config/config.php
    $container->loadFromExtension('cmf_menu', array(
        'persistence' => array(
            'phpcr' => array(
                'enabled'                     => false,
                'menu_basepath'               => '/cms/menu',
                'content_basepath'            => null,
                'prefetch'                    => 10,
                'manager_name'                => null,
                'menu_document_class'         => null,
                'node_document_class'         => null,
                'use_sonata_admin'            => 'auto',
                'menu_admin_class'            => null,
                'node_admin_class'            => null,
                'admin_recursive_breadcrumbs' => true,
            ),
        ),
    ));
    

enabled

type: boolean default: false

If true, PHPCR is enabled in the service container.

If the CoreBundle is registered, this will default to the value of cmf_core.persistence.phpcr.enabled.

PHPCR can be enabled by multiple ways such as:

  • YAML
    1
    2
    3
    4
    5
    6
    phpcr: ~ # use default configuration
    # or
    phpcr: true # straight way
    # or
    phpcr:
        manager: ... # or any other option under 'phpcr'
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    <persistence>
        <!-- use default configuration -->
        <phpcr />
    
        <!-- or setting it the straight way -->
        <phpcr>true</phpcr>
    
        <!-- or setting an option under 'phpcr' -->
        <phpcr manager="..." />
    </persistence>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    $container->loadFromExtension(..., array( // bundle configuration key, e.g. cmf_menu
        // ...
        'persistence' => array(
            'phpcr' => null, // use default configuration
            // or
            'phpcr' => true, // straight way
            // or
            'phpcr' => array(
                'manager' => '...', // or any other option under 'phpcr'
            ),
        ),
    ));
    

content_basepath

type: string default: /cms/content

Specifies the path in the PHPCR-ODM document hierarchy under which the content documents can be found. This is used by the admin class to pre-select the content branch of the document hierarchy in forms.

If the CoreBundle is registered, this will default to the value of %cmf_core.persistence.phpcr.basepath%/content

New in version 1.1: The pre-fetch functionality was added in MenuBundle 1.1.

prefetch

type: integer default: 10

When rendering a menu, the whole menu tree needs to be loaded. To reduce the number of database requests that PHPCR needs to make, this setting makes the tree loader pre-fetch all menu nodes in one call.

10 should be enough for most cases, if you have deeper menu structures you might want to increase this.

To disable menu pre-fetch completely, set this option to 0.

manager_name

type: string default: null

The name of the Doctrine Manager to use. null tells the manager registry to retrieve the default manager.

If the CoreBundle is registered, this will default to the value of cmf_core.persistence.phpcr.manager_name.

node_document_class

type: string default: Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode

Specifies the document class which should represent a single menu node.

This setting is used by the admin class.

use_sonata_admin

type: enum valid values: true|false|auto default: auto

If true, the admin classes are activated. If set to auto, they are activated only if the SonataPhpcrAdminBundle is present.

If the CoreBundle is registered, this will default to the value of cmf_core.persistence.phpcr.use_sonata_admin.

node_admin_class

type: string default: Symfony\Cmf\Bundle\MenuBundle\Admin\MenuNodeAdmin

The Sonata admin class to use for the menu node.

admin_recursive_breadcrumbs

type: boolean default: true

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

content_url_generator

New in version 1.2: This option was introduced in version 1.2.0. Prior to 1.2, this option is not available and the default service router is hardcoded.

type: string default: router

With this option, you can change what router should be used for generating URLs from menu nodes of type "content".

allow_empty_items

type: boolean default: false

Whether menu nodes without URL should be hidden or rendered as text without a link.

Admin Extensions

The admin_extensions section contains the configurations of the admin extensions that comes with the menu bundle.

Voter

type: array

The voters section enables you to enable and configure pre-defined voters.

  • YAML
    1
    2
    3
    4
    5
    6
    7
    # app/config/config.yml
    cmf_menu:
        # ...
        voters:
            content_identity:
                content_key: ~
            uri_prefix: false
    
  • XML
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <!-- app/config/config.xml -->
    <?xml version="1.0" charset="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
        <config xmlns="http://cmf.symfony.com/schema/dic/menu">
            <voter uri-prefix="false">
                <content-identity content-key="null" />
            </voter>
        </config>
    </container>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    // app/config/config.php
    $container->loadFromExtension('cmf_menu', array(
        'persistence' => array(
            'voters' => array(
                'content_identity' => array(
                    'content_key' => null,
                ),
                'uri_prefix' => false,
            ),
        ),
    ));
    

content_identity

type: array|boolean

Enable the RequestContentIdentityVoter.

Configuring this key is enough to enable it.

content_key

type: string default: contentDocument

The name of the parameter containing the content in the request.

Note

If you are using the RoutingBundle, you do not need to set this as it will default to DynamicRouter::CONTENT_KEY. If however you do not use the RoutingBundle, you will have to specify a key.

uri_prefix

type: boolean

Enable the UriPrefixVoter.

publish_workflow

New in version 1.1: The publish_workflow option was introduced in CmfMenuBundle 1.1.

This configures if the menu content voter for the publish workflow should be disabled, by default it is enabled if the CoreBundle is registered, and the cmf_core.publish_workflow is enabled.

For more information refer to the publish workflow documentation.

To disable the menu content voter, use:

  • YAML
    1
    2
    3
    4
    # app/config/config.yml
    cmf_core:
        publish_workflow:
            enabled: false
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    <!-- app/config/config.xml -->
    <?xml version="1.0" charset="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
    
        <config xmlns="http://cmf.symfony.com/schema/dic/core">
            <publish-workflow
                enabled="false"
            />
        </config>
    </container>
    
  • PHP
    1
    2
    3
    4
    5
    6
    // app/config/config.php
    $container->loadFromExtension('cmf_core', array(
        'publish_workflow' => array(
            'enabled' => false,
        ),
    ));
    

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.