diff --git a/DependencyInjection/Factory/AdapterFactoryInterface.php b/DependencyInjection/Factory/AdapterFactoryInterface.php index a49d83a..0fc8ad4 100644 --- a/DependencyInjection/Factory/AdapterFactoryInterface.php +++ b/DependencyInjection/Factory/AdapterFactoryInterface.php @@ -15,11 +15,9 @@ interface AdapterFactoryInterface /** * Creates the adapter, registers it and returns its id * - * @param ContainerBuilder $container - * @param string $id - * @param array $config - * - * @return string The Adapter service id in the DIC + * @param ContainerBuilder $container A ContainerBuilder instance + * @param string $id The id of the service + * @param array $config An array of configuration */ function create(ContainerBuilder $container, $id, array $config); diff --git a/DependencyInjection/Factory/InMemoryAdapterFactory.php b/DependencyInjection/Factory/InMemoryAdapterFactory.php index 4bf578b..78d1be4 100644 --- a/DependencyInjection/Factory/InMemoryAdapterFactory.php +++ b/DependencyInjection/Factory/InMemoryAdapterFactory.php @@ -18,14 +18,10 @@ class InMemoryAdapterFactory implements AdapterFactoryInterface */ public function create(ContainerBuilder $container, $id, array $config) { - $adapter = sprintf('knplabs_gaufrette.adapter.local.%s', $id); - $container - ->setDefinition($adapter, new DefinitionDecorator('knplabs_gaufrette.adapter.in_memory')) + ->setDefinition($id, new DefinitionDecorator('knplabs_gaufrette.adapter.in_memory')) ->replaceArgument(0, $config['files']) ; - - return $adapter; } /** diff --git a/DependencyInjection/Factory/LocalAdapterFactory.php b/DependencyInjection/Factory/LocalAdapterFactory.php index 5d1fb15..75bb526 100644 --- a/DependencyInjection/Factory/LocalAdapterFactory.php +++ b/DependencyInjection/Factory/LocalAdapterFactory.php @@ -18,15 +18,11 @@ class LocalAdapterFactory implements AdapterFactoryInterface */ public function create(ContainerBuilder $container, $id, array $config) { - $adapter = sprintf('knplabs_gaufrette.adapter.local.%s', $id); - $container - ->setDefinition($adapter, new DefinitionDecorator('knplabs_gaufrette.adapter.local')) + ->setDefinition($id, new DefinitionDecorator('knplabs_gaufrette.adapter.local')) ->replaceArgument(0, $config['directory']) ->replaceArgument(1, $config['create']) ; - - return $adapter; } /** diff --git a/DependencyInjection/Factory/SafeLocalAdapterFactory.php b/DependencyInjection/Factory/SafeLocalAdapterFactory.php index 49540d5..aa670e4 100644 --- a/DependencyInjection/Factory/SafeLocalAdapterFactory.php +++ b/DependencyInjection/Factory/SafeLocalAdapterFactory.php @@ -18,15 +18,11 @@ class SafeLocalAdapterFactory implements AdapterFactoryInterface */ public function create(ContainerBuilder $container, $id, array $config) { - $adapter = sprintf('knplabs_gaufrette.adapter.safe_local.%s', $id); - $container - ->setDefinition($adapter, new DefinitionDecorator('knplabs_gaufrette.adapter.safe_local')) + ->setDefinition($id, new DefinitionDecorator('knplabs_gaufrette.adapter.safe_local')) ->replaceArgument(0, $config['directory']) ->replaceArgument(1, $config['create']) ; - - return $adapter; } /** diff --git a/DependencyInjection/Factory/ServiceAdapterFactory.php b/DependencyInjection/Factory/ServiceAdapterFactory.php index aefe533..5578caa 100644 --- a/DependencyInjection/Factory/ServiceAdapterFactory.php +++ b/DependencyInjection/Factory/ServiceAdapterFactory.php @@ -17,7 +17,7 @@ class ServiceAdapterFactory implements AdapterFactoryInterface */ public function create(ContainerBuilder $container, $id, array $config) { - return $config['id']; + $container->setAlias($id, $config['id']); } /** diff --git a/DependencyInjection/KnplabsGaufretteExtension.php b/DependencyInjection/KnplabsGaufretteExtension.php index 2710bbd..0949791 100644 --- a/DependencyInjection/KnplabsGaufretteExtension.php +++ b/DependencyInjection/KnplabsGaufretteExtension.php @@ -55,7 +55,10 @@ class KnplabsGaufretteExtension extends Extension $adapter = null; foreach ($config as $key => $adapter) { if (array_key_exists($key, $factories)) { - return $factories[$key]->create($container, $name, $adapter); + $id = sprintf('gaufrette.%s_adapter', $name); + $factories[$key]->create($container, $id, $adapter); + + return $id; } }