BlockBundle
BlockBundle¶
This bundle provides Admin classes for all block types. Additionally, it provides an admin extension to generically edit block options.
Configuration¶
- YAML
1 2 3 4 5 6 7 8
# app/config/config.yml cmf_sonata_phpcr_admin_integration: bundles: block: enabled: false basepath: ~ enable_menu: auto menu_basepath: ~
- XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<!-- app/config/config.xml --> <?xml version="1.0" encoding="UTF-8" ?> <container xmlns="http://symfony.com/schema/dic/services"> <config xmlns="http://cmf.symfony.com/schema/dic/sonata-phpcr-admin-integration"> <bundles> <block enabled="false" basepath="null" enable-menu="auto" menu-basepath="null" /> </bundles> </config> </container>
- PHP
1 2 3 4 5 6 7 8 9 10 11
// app/config/config.php $container->loadFromExtension('cmf_sonata_phpcr_admin_integration', [ 'bundles' => [ 'block' => [ 'enabled' => false, 'basepath' => null, 'enable_menu' => 'auto', 'menu_basepath' => null, ], ], ];
enabled
¶
type: bool
default: false
If true
, the admin classes and extensions of this package are loaded and
available for Sonata Admin.
Tip
If you do not see this admin on the Sonata dashboard, you need to configure the dashboard to show the admin service in question. Read more about this in the Sonata Admin documentation.
Each admin service name follows the naming pattern
cmf_sonata_phpcr_admin_integration.block.<type>_admin
. For example, the
slideshow admin service is called cmf_sonata_phpcr_admin_integration.block.slideshow_admin
.
basepath
¶
type: string
default: first value of cmf_block.persistence.phpcr.block_basepaths
The path at which to create blocks with Sonata admin when you don't attach them to documents.
form_group
¶
type: string
default: form.group_metadata
The name of the form group to use in the admin extension.
The caption for the group is determined by translating the group name. If you change the group, be sure to also define a translation for it.
form_tab
¶
type: string
default: form.tab_general
The name of the form tab to use in the admin extension.
The caption for the tab is determined by translating the tab name. If you change the tab name, be sure to also define a translation for it.
Using the extension¶
To activate the extension in your admin classes, define the extension
configuration in the sonata_admin
section of your project configuration.
Assuming your blocks extend the BaseBlock
class (as all blocks provided by
the CMF BlockBundle do), you can add the following lines to your sonata admin
configuration:
- YAML
1 2 3 4 5 6
# app/config/config.yml sonata_admin: extensions: cmf_block.admin_extension.cache: extends: - Symfony\Cmf\Bundle\BlockBundle\Model\AbstractBlock
- XML
1 2 3 4 5 6 7 8 9 10 11
<!-- app/config/config.xml --> <?xml version="1.0" encoding="UTF-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <config xmlns="http://sonata-project.org/schema/dic/admin"> <extension id="cmf_block.admin_extension.cache"> <extend>Symfony\Cmf\Bundle\BlockBundle\Model\AbstractBlock</extend> </extension> </config> </container>
- PHP
1 2 3 4 5 6 7 8 9 10
// app/config/config.php $container->loadFromExtension('sonata_admin', array( 'extensions' => array( 'cmf.block.admin_extension.cache' => array( 'extends' => array( Symfony\Cmf\Bundle\BlockBundle\Model\AbstractBlock::class, ), ), ), ));
See the Sonata Admin extensions documentation for more information.
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.