瀏覽代碼

Implemented the ConfigurationInterface and moved the compilerPass to follow the conventions

Christophe Coevoet 14 年之前
父節點
當前提交
44f46e68ea

+ 1 - 5
DependencyInjection/AddDependencyCallsPass.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Sonata\AdminBundle\DependencyInjection;
+namespace Sonata\AdminBundle\DependencyInjection\Compiler;
 
 use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -30,10 +30,8 @@ class AddDependencyCallsPass implements CompilerPassInterface
      */
     public function process(ContainerBuilder $container)
     {
-
         $groups = $admins = $classes = array();
 
-        //
         $pool = $container->getDefinition('sonata.admin.pool');
 
         foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
@@ -77,7 +75,6 @@ class AddDependencyCallsPass implements CompilerPassInterface
         $pool->addMethodCall('setAdminGroups', array($groups));
         $pool->addMethodCall('setAdminClasses', array($classes));
 
-        //
         $routeLoader = $container->getDefinition('sonata.admin.route_loader');
         $routeLoader->addArgument($admins);
     }
@@ -91,7 +88,6 @@ class AddDependencyCallsPass implements CompilerPassInterface
      */
     public function applyDefaults(Definition $definition, array $attributes = array())
     {
-
         $definition->setScope(ContainerInterface::SCOPE_PROTOTYPE);
 
         $manager_type = $attributes[0]['manager_type'];

+ 4 - 5
DependencyInjection/Configuration.php

@@ -15,7 +15,6 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
 use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
 use Symfony\Component\Config\Definition\ConfigurationInterface;
 
-
 /**
  * This class contains the configuration information for the bundle
  *
@@ -24,21 +23,21 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
  *
  * @author Michael Williams <mtotheikle@gmail.com>
  */
-class Configuration
+class Configuration implements ConfigurationInterface
 {
     /**
      * Generates the configuration tree.
      *
-     * @return \Symfony\Component\Config\Definition\NodeInterface
+     * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder
      */
-    public function getConfigTree($kernelDebug)
+    public function getConfigTreeBuilder()
     {
         $treeBuilder = new TreeBuilder();
         $rootNode = $treeBuilder->root('sonata_admin', 'array');
 
         $this->addTemplateSection($rootNode);
 
-        return $treeBuilder->buildTree();
+        return $treeBuilder;
     }
 
     private function addTemplateSection(ArrayNodeDefinition $rootNode)

+ 1 - 1
DependencyInjection/SonataAdminExtension.php

@@ -55,7 +55,7 @@ class SonataAdminExtension extends Extension
 
         $configuration = new Configuration();
         $processor = new Processor();
-        $config = $processor->process($configuration->getConfigTree($container->getParameter('kernel.debug')), $configs);
+        $config = $processor->processConfiguration($configuration, $configs);
 
         // setups parameters with values in config.yml, default values from external files used if not
         $this->configSetupTemplates($config, $container);

+ 1 - 2
SonataAdminBundle.php

@@ -12,11 +12,10 @@ namespace Sonata\AdminBundle;
 
 use Symfony\Component\HttpKernel\Bundle\Bundle;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Sonata\AdminBundle\DependencyInjection\AddDependencyCallsPass;
+use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsPass;
 
 class SonataAdminBundle extends Bundle
 {
-
     public function build(ContainerBuilder $container)
     {
         parent::build($container);