diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 3146ea1..b805440 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -24,6 +24,7 @@ public function getConfigTreeBuilder() ->children() ->scalarNode('class')->isRequired()->cannotBeEmpty()->end() ->scalarNode('storage_class')->defaultValue(Storage::class)->cannotBeEmpty()->end() + ->booleanNode('storage_autowire')->defaultFalse()->end() ->scalarNode('collection')->isRequired()->cannotBeEmpty()->end() ->scalarNode('database')->defaultValue(null)->end() ->scalarNode('hydrator')->defaultValue(false)->end() diff --git a/DependencyInjection/YadmExtension.php b/DependencyInjection/YadmExtension.php index 8d91602..f280f55 100644 --- a/DependencyInjection/YadmExtension.php +++ b/DependencyInjection/YadmExtension.php @@ -56,6 +56,12 @@ public function load(array $configs, ContainerBuilder $container) ->addArgument(new Reference('yadm.changes_collector')) ; + if ($modelConfig['storage_autowire']) { + $container->setAlias($modelConfig['storage_class'], sprintf('yadm.%s.storage', $name)) + ->setPublic(true) + ; + } + if ($modelConfig['pessimistic_lock']) { $container->register(sprintf('yadm.%s.pessimistic_lock_collection', $name), Collection::class) ->setFactory([new Reference('yadm.collection_factory'), 'create'])