SonataPhpcrAdminIntegrationBundle

SonataPhpcrAdminIntegrationBundle

The SonataPhpcrAdminIntegrationBundle provides admin services for the Sonata Admin tool. Additionally, it provides admin extensions to improve your custom admin services.

Installation

You can install this bundle with composer using the symfony-cmf/sonata-phpcr-admin-integration-bundle package on Packagist.

As this bundle integrates the SonataDoctrinePhpcrAdminBundle, please follow its official installation guide to install the bundle.

After this, enable both the CmfSonataPhpcrAdminIntegrationBundle as well as the SonataDoctrinePhpcrAdminBundle related bundles:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// app/appKernel.php

// ...
public function registerBundles()
{
    $bundles = array(
        // ...

        // SonataAdminBundle related
        new Sonata\CoreBundle\SonataCoreBundle(),
        new Sonata\BlockBundle\SonataBlockBundle(),
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
        new Sonata\AdminBundle\SonataAdminBundle(),

        // SonataDoctrinePhpcrAdminBundle related
        new Symfony\Cmf\Bundle\TreeBrowserBundle\CmfTreeBrowserBundle(),
        new Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle(),

        // CmfSonataPhpcrAdminIntegrationBundle
        new Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\CmfSonataPhpcrAdminIntegrationBundle(),
    );

    // ...

    return $bundles;
}

Usage

The integration bundle provides admins for the CMF bundles. The related configuration section of a bundle becomes available whenever a CMF bundle is registered in the AppKernel. For instance, to enable the admin integration for the CmfContentBundle, use the following config:

  • YAML
    1
    2
    3
    4
    # app/config/config.yml
    cmf_sonata_phpcr_admin_integration:
        bundles:
            content: ~
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    <!-- app/config/config.xml -->
    <?xml version="2.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
        xsd:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
            http://cmf.symfony.com/schema/dic/sonata_admin_integration http://cmf.symfony.com/schema/dic/sonata_admin_integration/sonata_admin_integration.xsd"
    >
    
        <config xmlns="http://cmf.symfony.com/schema/dic/sonata_admin_integration">
            <bundles>
                <content/>
            </bundles>
        </config>
    </container>
    
  • PHP
    1
    2
    3
    4
    5
    6
    // app/config/config.php
    $container->loadFromExtension('cmf_sonata_phpcr_admin_integration', [
        'bundles' => [
            'content' => true,
        ],
    ]);
    

Adding Admins to the Dashboard

To see an admin on the dashboard, configure the Sonata Admin accordingly. For example, to add the routing admin, you would add the following configuration:

  • YAML
    1
    2
    3
    4
    5
    6
    7
    sonata_admin:
        dashboard:
            groups:
                blocks:
                    label: URLs
                    items:
                        - cmf_sonata_phpcr_admin_integration.routing.route_admin
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
    
        <config xmlns="http://example.org/schema/dic/sonata_admin">
            <dashboard>
                <group id="blocks"
                    label="URLs">
                    <item>cmf_sonata_phpcr_admin_integration.routing.route_admin</item>
                </group>
            </dashboard>
        </config>
    
    </container>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    $container->loadFromExtension('sonata_admin', array(
        'dashboard' => array(
            'groups' => array(
                'blocks' => array(
                    'label' => 'URLs',
                    'items' => array(
                        'cmf_sonata_phpcr_admin_integration.routing.route_admin',
                    ),
                ),
            ),
        ),
    ));
    

You can also embed an admin directly into other admin classes using the sonata_type_admin form type. Please refer to the Sonata Admin documentation for further information.

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