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
    # app/config/config.yml
    cmf_menu:
        persistence:
            phpcr:
                enabled:                     false
                menu_basepath:               /cms/menu
                content_basepath:            /cms/content
                manager_name:                ~
                prefetch:                    10
                menu_document_class:         Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu
                node_document_class:         Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    <!-- 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="/cms/content"
                    manager-name="null"
                    prefetch="10"
                    menu-document-class="Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu"
                    node-document-class="Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode"
                />
            </persistence>
        </config>
    </container>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    //  app/config/config.php
    $container->loadFromExtension('cmf_menu', [
        'persistence' => [
            'phpcr' => [
                'enabled'                     => false,
                'menu_basepath'               => '/cms/menu',
                'content_basepath'            => '/cms/content',
                'manager_name'                => null,
                'prefetch'                    => 10,
                'menu_document_class'         => \Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu::class,
                'node_document_class'         => \Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode::class,
            ],
        ],
    ]);
    

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 sonata admin integration to know which subtree to show when selecting content for menu nodes.

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

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.

content_url_generator

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.

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', [
        'persistence' => [
            'voters' => [
                'content_identity' => [
                    '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

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', [
        'publish_workflow' => [
            'enabled' => false,
        ],
    ]);
    

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