Преглед на файлове

add filter compiler pass

Thomas Rabaix преди 13 години
родител
ревизия
27e256e202
променени са 3 файла, в които са добавени 13 реда и са изтрити 8 реда
  1. 10 6
      DependencyInjection/Compiler/AddFilterTypeCompilerPasss.php
  2. 1 0
      DependencyInjection/SonataAdminExtension.php
  3. 2 2
      SonataAdminBundle.php

+ 10 - 6
DependencyInjection/Compiler/AddFilterTypeCompilerPasss.php

@@ -25,13 +25,17 @@ class AddFilterTypeCompilerPass implements CompilerPassInterface
 {
     public function process(ContainerBuilder $container)
     {
-       // ShowBuilder
-        $definition = $container->getDefinition('sonata.admin.guesser.orm_show_chain');
-        $services = array();
-        foreach($container->findTaggedServiceIds('sonata.admin.guesser.orm_show') as $id => $attributes) {
-            $services[] = new Reference($id);
+        $definition = $container->getDefinition('sonata.admin.builder.filter.factory');
+        $types = array();
+
+        foreach($container->findTaggedServiceIds('sonata.admin.filter.type') as $id => $attributes) {
+            $name = $attributes[0]['alias'];
+
+            $container->getDefinition($id)->setScope(ContainerInterface::SCOPE_PROTOTYPE);
+
+            $types[$name] = $id;
         }
 
-        $definition->replaceArgument(0, $services);
+        $definition->replaceArgument(1, $types);
     }
 }

+ 1 - 0
DependencyInjection/SonataAdminExtension.php

@@ -49,6 +49,7 @@ class SonataAdminExtension extends Extension
         $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
         $loader->load('templates.xml');
         $loader->load('doctrine_orm.xml');
+        $loader->load('doctrine_orm_filter_types.xml');
         $loader->load('twig.xml');
         $loader->load('core.xml');
         $loader->load('form_types.xml');

+ 2 - 2
SonataAdminBundle.php

@@ -14,14 +14,14 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass;
 use Sonata\AdminBundle\DependencyInjection\Compiler\AddGuesserCompilerPass;
+use Sonata\AdminBundle\DependencyInjection\Compiler\AddFilterTypeCompilerPass;
 
 class SonataAdminBundle extends Bundle
 {
     public function build(ContainerBuilder $container)
     {
-        parent::build($container);
-
         $container->addCompilerPass(new AddDependencyCallsCompilerPass());
         $container->addCompilerPass(new AddGuesserCompilerPass());
+        $container->addCompilerPass(new AddFilterTypeCompilerPass());
     }
 }