Browse Source

Upgrade Block class to use the lastest version of BlockBundle

Thomas Rabaix 12 years ago
parent
commit
5f17205b80
2 changed files with 15 additions and 8 deletions
  1. 14 7
      Block/AdminListBlockService.php
  2. 1 1
      composer.json

+ 14 - 7
Block/AdminListBlockService.php

@@ -11,6 +11,7 @@
 
 namespace Sonata\AdminBundle\Block;
 
+use Sonata\BlockBundle\Block\BlockContextInterface;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
 
@@ -20,6 +21,8 @@ use Sonata\AdminBundle\Admin\Pool;
 
 use Sonata\BlockBundle\Model\BlockInterface;
 use Sonata\BlockBundle\Block\BaseBlockService;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
 
 /**
  *
@@ -44,12 +47,12 @@ class AdminListBlockService extends BaseBlockService
     /**
      * {@inheritdoc}
      */
-    public function execute(BlockInterface $block, Response $response = null)
+    public function execute(BlockContextInterface $blockContext, Response $response = null)
     {
-        $settings = array_merge($this->getDefaultSettings(), $block->getSettings());
-
         $dashboardGroups = $this->pool->getDashboardGroups();
 
+        $settings = $blockContext->getSettings();
+
         $visibleGroups = array();
         foreach ($dashboardGroups as $name => $dashboardGroup) {
             if (!$settings['groups'] || in_array($name, $settings['groups'])) {
@@ -58,7 +61,7 @@ class AdminListBlockService extends BaseBlockService
         }
 
         return $this->renderResponse($this->pool->getTemplate('list_block'), array(
-            'block'         => $block,
+            'block'         => $blockContext->getBlock(),
             'settings'      => $settings,
             'admin_pool'    => $this->pool,
             'groups'        => $visibleGroups
@@ -92,10 +95,14 @@ class AdminListBlockService extends BaseBlockService
     /**
      * {@inheritdoc}
      */
-    public function getDefaultSettings()
+    public function setDefaultSettings(OptionsResolverInterface $resolver)
     {
-        return array(
+        $resolver->setDefaults(array(
             'groups' => false
-        );
+        ));
+
+        $resolver->setAllowedTypes(array(
+            'groups' => array('bool')
+        ));
     }
 }

+ 1 - 1
composer.json

@@ -29,7 +29,7 @@
         "knplabs/knp-menu-bundle": "~1.1",
         "sonata-project/jquery-bundle": "1.8.*",
         "sonata-project/exporter": "1.*",
-        "sonata-project/block-bundle": "2.2.0",
+        "sonata-project/block-bundle": ">=2.2.1,<3.0",
         "doctrine/common": ">=2.2,<3.0"
     },
     "require-dev": {