SonataDoctrineORMAdminExtension.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the Sonata project.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\DoctrineORMAdminBundle\DependencyInjection;
  11. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\Reference;
  14. use Symfony\Component\DependencyInjection\Definition;
  15. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  16. use Symfony\Component\Config\FileLocator;
  17. use Symfony\Component\Config\Resource\FileResource;
  18. use Symfony\Component\Config\Definition\Processor;
  19. /**
  20. * SonataAdminBundleExtension
  21. *
  22. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  23. * @author Michael Williams <michael.williams@funsational.com>
  24. */
  25. class SonataDoctrineORMAdminExtension extends Extension
  26. {
  27. /**
  28. *
  29. * @param array $configs An array of configuration settings
  30. * @param ContainerBuilder $container A ContainerBuilder instance
  31. */
  32. public function load(array $config, ContainerBuilder $container)
  33. {
  34. $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
  35. $loader->load('doctrine_orm.xml');
  36. $loader->load('doctrine_orm_filter_types.xml');
  37. $configuration = new Configuration();
  38. $processor = new Processor();
  39. $config = $processor->processConfiguration($configuration, $config);
  40. $pool = $container->getDefinition('sonata.admin.manager.orm');
  41. $pool->addMethodCall('__hack_doctrine_orm__', $config);
  42. }
  43. }