| @@ 9-47 (lines=39) @@ | ||
| 6 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
| 7 | use Symfony\Component\DependencyInjection\DefinitionDecorator; |
|
| 8 | ||
| 9 | class FileSystemLoaderFactory implements LoaderFactoryInterface |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * {@inheritdoc} |
|
| 13 | */ |
|
| 14 | public function create(ContainerBuilder $container, $loaderName, array $config) |
|
| 15 | { |
|
| 16 | $loaderDefinition = new DefinitionDecorator('liip_imagine.binary.loader.prototype.filesystem'); |
|
| 17 | $loaderDefinition->replaceArgument(2, $config['data_root']); |
|
| 18 | $loaderDefinition->addTag('liip_imagine.binary.loader', array( |
|
| 19 | 'loader' => $loaderName, |
|
| 20 | )); |
|
| 21 | $loaderId = 'liip_imagine.binary.loader.'.$loaderName; |
|
| 22 | ||
| 23 | $container->setDefinition($loaderId, $loaderDefinition); |
|
| 24 | ||
| 25 | return $loaderId; |
|
| 26 | } |
|
| 27 | ||
| 28 | /** |
|
| 29 | * {@inheritdoc} |
|
| 30 | */ |
|
| 31 | public function getName() |
|
| 32 | { |
|
| 33 | return 'filesystem'; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * {@inheritdoc} |
|
| 38 | */ |
|
| 39 | public function addConfiguration(ArrayNodeDefinition $builder) |
|
| 40 | { |
|
| 41 | $builder |
|
| 42 | ->children() |
|
| 43 | ->scalarNode('data_root')->defaultValue('%kernel.root_dir%/../web')->cannotBeEmpty()->end() |
|
| 44 | ->end() |
|
| 45 | ; |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| @@ 10-48 (lines=39) @@ | ||
| 7 | use Symfony\Component\DependencyInjection\DefinitionDecorator; |
|
| 8 | use Symfony\Component\DependencyInjection\Reference; |
|
| 9 | ||
| 10 | class FlysystemLoaderFactory implements LoaderFactoryInterface |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * {@inheritdoc} |
|
| 14 | */ |
|
| 15 | public function create(ContainerBuilder $container, $loaderName, array $config) |
|
| 16 | { |
|
| 17 | $loaderDefinition = new DefinitionDecorator('liip_imagine.binary.loader.prototype.flysystem'); |
|
| 18 | $loaderDefinition->replaceArgument(1, new Reference($config['filesystem_service'])); |
|
| 19 | $loaderDefinition->addTag('liip_imagine.binary.loader', array( |
|
| 20 | 'loader' => $loaderName, |
|
| 21 | )); |
|
| 22 | $loaderId = 'liip_imagine.binary.loader.'.$loaderName; |
|
| 23 | ||
| 24 | $container->setDefinition($loaderId, $loaderDefinition); |
|
| 25 | ||
| 26 | return $loaderId; |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * {@inheritdoc} |
|
| 31 | */ |
|
| 32 | public function getName() |
|
| 33 | { |
|
| 34 | return 'flysystem'; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * {@inheritdoc} |
|
| 39 | */ |
|
| 40 | public function addConfiguration(ArrayNodeDefinition $builder) |
|
| 41 | { |
|
| 42 | $builder |
|
| 43 | ->children() |
|
| 44 | ->scalarNode('filesystem_service')->isRequired()->cannotBeEmpty()->end() |
|
| 45 | ->end() |
|
| 46 | ; |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||