vendor/liip/imagine-bundle/DependencyInjection/Factory/Resolver/WebPathResolverFactory.php line 49

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the `liip/LiipImagineBundle` project.
  4. *
  5. * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
  6. *
  7. * For the full copyright and license information, please view the LICENSE.md
  8. * file that was distributed with this source code.
  9. */
  10. namespace Liip\ImagineBundle\DependencyInjection\Factory\Resolver;
  11. use Liip\ImagineBundle\Utility\Framework\SymfonyFramework;
  12. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. class WebPathResolverFactory extends AbstractResolverFactory
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function create(ContainerBuilder $container, $resolverName, array $config)
  20. {
  21. $resolverDefinition = $this->getChildResolverDefinition();
  22. $resolverDefinition->replaceArgument(2, $config['web_root']);
  23. $resolverDefinition->replaceArgument(3, $config['cache_prefix']);
  24. $resolverDefinition->addTag('liip_imagine.cache.resolver', [
  25. 'resolver' => $resolverName,
  26. ]);
  27. $resolverId = 'liip_imagine.cache.resolver.';
  28. $container->setDefinition($resolverId.$resolverName, $resolverDefinition);
  29. return $resolverId;
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function getName()
  35. {
  36. return 'web_path';
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function addConfiguration(ArrayNodeDefinition $builder)
  42. {
  43. $builder
  44. ->children()
  45. ->scalarNode('web_root')
  46. ->defaultValue(SymfonyFramework::getContainerResolvableRootWebPath())
  47. ->cannotBeEmpty()
  48. ->end()
  49. ->scalarNode('cache_prefix')
  50. ->defaultValue('media/cache')
  51. ->cannotBeEmpty()
  52. ->end()
  53. ->end();
  54. }
  55. }