Permalink
Browse files

make slideshow optional and root path configurable

  • Loading branch information...
dbu committed Mar 13, 2013
1 parent 84e2de9 commit 37ab49e9cbb2ac804410680b25ddff4c9414c62e
View
@@ -9,12 +9,24 @@ class SlideshowAdmin extends MinimalSlideshowAdmin
protected $baseRouteName = 'symfony_cmf_block.slideshow_admin';
protected $baseRoutePattern = 'symfony_cmf/block/slideshow';
+ /**
+ * Path to where new slideshow blocks may be attached
+ *
+ * @var string
+ */
+ protected $blockRoot;
+
+ public function setBlockRoot($blockRoot)
+ {
+ $this->blockRoot = $blockRoot;
+ }
@dbu

dbu Mar 13, 2013

Owner

@elHornair this was to make the root configurable

+
protected function configureFormFields(FormMapper $formMapper)
{
parent::configureFormFields($formMapper);
$formMapper
->with('form.group_general')
- ->add('parentDocument', 'doctrine_phpcr_odm_tree', array('root_node' => '/cms/content/blocks_general', 'choice_list' => array(), 'select_root_node' => true))
+ ->add('parentDocument', 'doctrine_phpcr_odm_tree', array('root_node' => $this->blockRoot, 'choice_list' => array(), 'select_root_node' => true))
->add('name', 'text')
->end();
}
@@ -28,7 +28,9 @@ public function getConfigTreeBuilder()
$rootNode
->children()
->scalarNode('document_manager_name')->defaultValue('default')->end()
- ->scalarNode('content_basepath')->defaultNull('/cms/content')->end()
+ ->scalarNode('content_basepath')->defaultValue('/cms/content')->end()
+ ->scalarNode('block_basepath')->defaultValue('/cms/content')->end()
@dbu

dbu Mar 13, 2013

Owner

and this to have it in the configuration with a default

+ ->scalarNode('slideshow')->defaultValue(false)->end()
->scalarNode('simple_admin_class')->defaultNull()->end()
->scalarNode('simple_document_class')->defaultNull()->end()
->scalarNode('container_admin_class')->defaultNull()->end()
@@ -12,6 +12,9 @@ public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);
+ $container->setParameter($this->getAlias() . '.content_basepath', $config['content_basepath']);
+ $container->setParameter($this->getAlias() . '.block_basepath', $config['block_basepath']);
@dbu

dbu Mar 13, 2013

Owner

to have the parameter available for the service definitions

+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
@@ -32,6 +35,10 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter($this->getAlias() . '.multilang.locales', $config['multilang']['locales']);
}
+ if ($config['slideshow']) {
+ $loader->load('slideshow.xml');
+ }
+
if (isset($config['simple_document_class'])) {
$container->setParameter($this->getAlias() . '.simple_document_class', $config['simple_document_class']);
}
@@ -89,6 +96,10 @@ public function loadSonataAdmin($config, XmlFileLoader $loader, ContainerBuilder
if (isset($config['simple_admin_class'])) {
$container->setParameter($this->getAlias() . '.' . $prefix . 'simple_admin_class', $config['simple_admin_class']);
}
+
+ if ($config['slideshow']) {
+ $loader->load('slideshow.admin.xml');
+ }
}
public function loadSonataCache($config, XmlFileLoader $loader, ContainerBuilder $container)
View
@@ -7,11 +7,6 @@
<parameters>
<parameter key="symfony_cmf_block.simple_admin_class">Symfony\Cmf\Bundle\BlockBundle\Admin\SimpleBlockAdmin</parameter>
<parameter key="symfony_cmf_block.simple_document_class">Symfony\Cmf\Bundle\BlockBundle\Document\SimpleBlock</parameter>
- <parameter key="symfony_cmf_block.slideshow_admin_class">Symfony\Cmf\Bundle\BlockBundle\Admin\SlideshowAdmin</parameter>
- <parameter key="symfony_cmf_block.minimal_slideshow_admin_class">Symfony\Cmf\Bundle\BlockBundle\Admin\MinimalSlideshowAdmin</parameter>
- <parameter key="symfony_cmf_block.slideshow_document_class">Symfony\Cmf\Bundle\BlockBundle\Document\SlideshowBlock</parameter>
- <parameter key="symfony_cmf_block.slideshow_item_admin_class">Symfony\Cmf\Bundle\BlockBundle\Admin\SlideshowItemAdmin</parameter>
- <parameter key="symfony_cmf_block.slideshow_item_document_class">Symfony\Cmf\Bundle\BlockBundle\Document\SlideshowItemBlock</parameter>
</parameters>
<services>
@@ -30,43 +25,5 @@
</call>
</service>
- <service id="symfony_cmf_block.minimal_slideshow_admin" class="%symfony_cmf_block.minimal_slideshow_admin_class%">
- <tag name="sonata.admin" manager_type="doctrine_phpcr" group="dashboard.group_routing" label_catalogue="SymfonyCmfBlockBundle" label="dashboard.minimal_slideshow_block" label_translator_strategy="sonata.admin.label.strategy.underscore" />
- <argument/>
- <argument>%symfony_cmf_block.slideshow_document_class%</argument>
- <argument>SonataAdminBundle:CRUD</argument>
-
- <call method="setRouteBuilder">
- <argument type="service" id="sonata.admin.route.path_info_slashes" />
- </call>
- </service>
-
- <service id="symfony_cmf_block.slideshow_admin" class="%symfony_cmf_block.slideshow_admin_class%">
- <tag name="sonata.admin" manager_type="doctrine_phpcr" group="dashboard.group_content" label_catalogue="SymfonyCmfBlockBundle" label="dashboard.label_slideshow_block" label_translator_strategy="sonata.admin.label.strategy.underscore" />
- <argument/>
- <argument>%symfony_cmf_block.slideshow_document_class%</argument>
- <argument>SonataAdminBundle:CRUD</argument>
-
- <call method="setRouteBuilder">
- <argument type="service" id="sonata.admin.route.path_info_slashes" />
- </call>
-
- </service>
-
- <service id="symfony_cmf_block.slideshow_item_admin" class="%symfony_cmf_block.slideshow_item_admin_class%">
- <tag name="sonata.admin" manager_type="doctrine_phpcr" group="dashboard.group_content" label_catalogue="SymfonyCmfBlockBundle" label="dashboard.label_slideshow_item_block" label_translator_strategy="sonata.admin.label.strategy.underscore" />
- <argument/>
- <argument>%symfony_cmf_block.slideshow_item_document_class%</argument>
- <argument>SonataAdminBundle:CRUD</argument>
-
- <call method="setRouteBuilder">
- <argument type="service" id="sonata.admin.route.path_info_slashes" />
- </call>
-
- <call method="setRoot">
- <argument>%symfony_cmf_block.content_basepath%</argument>
- </call>
- </service>
-
</services>
</container>
@@ -7,7 +7,6 @@
<parameters>
<parameter key="symfony_cmf_block.container_admin_class">Symfony\Cmf\Bundle\BlockBundle\Admin\ContainerBlockAdmin</parameter>
<parameter key="symfony_cmf_block.container_document_class">Symfony\Cmf\Bundle\BlockBundle\Document\ContainerBlock</parameter>
- <parameter key="symfony_cmf_block.content_basepath">/cms/content</parameter>
</parameters>
<services>
@@ -45,23 +45,6 @@
<argument type="service" id="http_kernel" />
</service>
- <!--container block service is reused for slideshows -->
- <service id="symfony_cmf.block.slideshow" class="Symfony\Cmf\Bundle\BlockBundle\Block\ContainerBlockService">
- <tag name="sonata.block" />
- <argument>symfony_cmf.block.slideshow</argument>
- <argument type="service" id="templating" />
- <argument type="service" id="sonata.block.renderer" />
- <argument>SymfonyCmfBlockBundle:Block:block_slideshow.html.twig</argument>
- </service>
-
- <!-- simple block service is reused for slideshow items -->
- <service id="symfony_cmf.block.slideshow_item" class="Symfony\Cmf\Bundle\BlockBundle\Block\SimpleBlockService">
- <tag name="sonata.block" />
- <argument>symfony_cmf.block.slideshow_item</argument>
- <argument type="service" id="templating" />
- <argument>SymfonyCmfBlockBundle:Block:block_slideshow_item.html.twig</argument>
- </service>
-
<service id="symfony_cmf.block.rss_controller" class="%symfony_cmf_block.rss_controller_class%" >
<call method="setContainer">
<argument type="service" id="service_container" />
@@ -0,0 +1,60 @@
+<?xml version="1.0" ?>
+
+<container xmlns="http://symfony.com/schema/dic/services"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+ <parameters>
+ <parameter key="symfony_cmf_block.slideshow_admin_class">Symfony\Cmf\Bundle\BlockBundle\Admin\SlideshowAdmin</parameter>
+ <parameter key="symfony_cmf_block.minimal_slideshow_admin_class">Symfony\Cmf\Bundle\BlockBundle\Admin\MinimalSlideshowAdmin</parameter>
+ <parameter key="symfony_cmf_block.slideshow_document_class">Symfony\Cmf\Bundle\BlockBundle\Document\SlideshowBlock</parameter>
+ <parameter key="symfony_cmf_block.slideshow_item_admin_class">Symfony\Cmf\Bundle\BlockBundle\Admin\SlideshowItemAdmin</parameter>
+ <parameter key="symfony_cmf_block.slideshow_item_document_class">Symfony\Cmf\Bundle\BlockBundle\Document\SlideshowItemBlock</parameter>
+ </parameters>
+
+ <services>
+
+ <service id="symfony_cmf_block.minimal_slideshow_admin" class="%symfony_cmf_block.minimal_slideshow_admin_class%">
+ <tag name="sonata.admin" manager_type="doctrine_phpcr" group="dashboard.group_routing" label_catalogue="SymfonyCmfBlockBundle" label="dashboard.minimal_slideshow_block" label_translator_strategy="sonata.admin.label.strategy.underscore" />
+ <argument/>
+ <argument>%symfony_cmf_block.slideshow_document_class%</argument>
+ <argument>SonataAdminBundle:CRUD</argument>
+
+ <call method="setRouteBuilder">
+ <argument type="service" id="sonata.admin.route.path_info_slashes" />
+ </call>
+ </service>
+
+ <service id="symfony_cmf_block.slideshow_admin" class="%symfony_cmf_block.slideshow_admin_class%">
+ <tag name="sonata.admin" manager_type="doctrine_phpcr" group="dashboard.group_content" label_catalogue="SymfonyCmfBlockBundle" label="dashboard.label_slideshow_block" label_translator_strategy="sonata.admin.label.strategy.underscore" />
+ <argument/>
+ <argument>%symfony_cmf_block.slideshow_document_class%</argument>
+ <argument>SonataAdminBundle:CRUD</argument>
+
+ <call method="setRouteBuilder">
+ <argument type="service" id="sonata.admin.route.path_info_slashes" />
+ </call>
+
+ <call method="setBlockRoot">
+ <argument>%symfony_cmf_block.block_basepath%</argument>
+ </call>
@dbu

dbu Mar 13, 2013

Owner

and finally this to set it on the admin class

+
+ </service>
+
+ <service id="symfony_cmf_block.slideshow_item_admin" class="%symfony_cmf_block.slideshow_item_admin_class%">
+ <tag name="sonata.admin" manager_type="doctrine_phpcr" group="dashboard.group_content" label_catalogue="SymfonyCmfBlockBundle" label="dashboard.label_slideshow_item_block" label_translator_strategy="sonata.admin.label.strategy.underscore" />
+ <argument/>
+ <argument>%symfony_cmf_block.slideshow_item_document_class%</argument>
+ <argument>SonataAdminBundle:CRUD</argument>
+
+ <call method="setRouteBuilder">
+ <argument type="service" id="sonata.admin.route.path_info_slashes" />
+ </call>
+
+ <call method="setRoot">
+ <argument>%symfony_cmf_block.content_basepath%</argument>
+ </call>
+ </service>
+
+ </services>
+</container>
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<container xmlns="http://symfony.com/schema/dic/services"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+ <services>
+
+ <!--container block service is reused for slideshows -->
+ <service id="symfony_cmf.block.slideshow" class="Symfony\Cmf\Bundle\BlockBundle\Block\ContainerBlockService">
+ <tag name="sonata.block" />
+ <argument>symfony_cmf.block.slideshow</argument>
+ <argument type="service" id="templating" />
+ <argument type="service" id="sonata.block.renderer" />
+ <argument>SymfonyCmfBlockBundle:Block:block_slideshow.html.twig</argument>
+ </service>
+
+ <!-- simple block service is reused for slideshow items -->
+ <service id="symfony_cmf.block.slideshow_item" class="Symfony\Cmf\Bundle\BlockBundle\Block\SimpleBlockService">
+ <tag name="sonata.block" />
+ <argument>symfony_cmf.block.slideshow_item</argument>
+ <argument type="service" id="templating" />
+ <argument>SymfonyCmfBlockBundle:Block:block_slideshow_item.html.twig</argument>
+ </service>
+
+ </services>
+</container>

1 comment on commit 37ab49e

Member

elHornair commented on 37ab49e Mar 14, 2013

Cool, thx a lot @dbu for your notes on the configuration of the root

Please sign in to comment.