From 00a3fab9bcd25ecf4b2d8fe415d856f9ad6c3c14 Mon Sep 17 00:00:00 2001 From: Johannes Schmitt Date: Tue, 27 Sep 2011 10:50:39 +0200 Subject: [PATCH 1/2] adds AmazonS3 adapter factory --- .../Factory/AmazonS3AdapterFactory.php | 54 +++++++++++++++++++ Resources/config/adapter_factories.xml | 3 ++ Resources/config/gaufrette.xml | 1 + 3 files changed, 58 insertions(+) create mode 100644 DependencyInjection/Factory/AmazonS3AdapterFactory.php diff --git a/DependencyInjection/Factory/AmazonS3AdapterFactory.php b/DependencyInjection/Factory/AmazonS3AdapterFactory.php new file mode 100644 index 0000000..f583d7b --- /dev/null +++ b/DependencyInjection/Factory/AmazonS3AdapterFactory.php @@ -0,0 +1,54 @@ +setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.amazon_s3')) + ->addArgument(new Reference($config['amazon_s3_id'])) + ->addArgument($config['bucket_name']) + ->addArgument($config['create']) + ; + } + + /** + * Returns the key for the factory configuration + * + * @return string + */ + public function getKey() + { + return 'amazon_s3'; + } + + /** + * Adds configuration nodes for the factory + * + * @param NodeBuilder $builder + */ + public function addConfiguration(NodeDefinition $builder) + { + $builder + ->children() + ->scalarNode('amazon_s3_id')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end() + ->booleanNode('create')->defaultFalse()->end() + ->end() + ; + } +} \ No newline at end of file diff --git a/Resources/config/adapter_factories.xml b/Resources/config/adapter_factories.xml index 415e87e..52359ca 100644 --- a/Resources/config/adapter_factories.xml +++ b/Resources/config/adapter_factories.xml @@ -17,6 +17,9 @@ + + + diff --git a/Resources/config/gaufrette.xml b/Resources/config/gaufrette.xml index 886ecc8..10cc03c 100644 --- a/Resources/config/gaufrette.xml +++ b/Resources/config/gaufrette.xml @@ -19,6 +19,7 @@ + From f97f2be079ff70bd4429b078b867bc95dc5d2afd Mon Sep 17 00:00:00 2001 From: Johannes Schmitt Date: Tue, 27 Sep 2011 10:50:58 +0200 Subject: [PATCH 2/2] marks filesystem definition as non-public when alias is defined --- DependencyInjection/KnpGaufretteExtension.php | 1 + 1 file changed, 1 insertion(+) diff --git a/DependencyInjection/KnpGaufretteExtension.php b/DependencyInjection/KnpGaufretteExtension.php index a0c7134..39e9d47 100644 --- a/DependencyInjection/KnpGaufretteExtension.php +++ b/DependencyInjection/KnpGaufretteExtension.php @@ -87,6 +87,7 @@ class KnpGaufretteExtension extends Extension ; if (!empty($config['alias'])) { + $container->getDefinition($id)->setPublic(false); $container->setAlias($config['alias'], $id); }