GregwarImageExtension.php 1022B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Gregwar\ImageBundle\DependencyInjection;
  3. use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  4. use Symfony\Component\DependencyInjection\ContainerBuilder;
  5. use Symfony\Component\DependencyInjection\Definition;
  6. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  7. use Symfony\Component\Config\FileLocator;
  8. /**
  9. * Loading configuration
  10. *
  11. * @author Gregwar <g.passault@gmail.com>
  12. */
  13. class GregwarImageExtension extends Extension
  14. {
  15. public function load(array $configs, ContainerBuilder $container)
  16. {
  17. $cacheDir = 'cache';
  18. $config = array();
  19. foreach ($configs as $subConfig) {
  20. $config = array_merge($config, $subConfig);
  21. }
  22. if (isset($config['cache_dir']))
  23. $cacheDir = $config['cache_dir'];
  24. $container->setParameter('gregwar_image.cache_dir', $cacheDir);
  25. $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
  26. $loader->load('services.yml');
  27. }
  28. }