diff --git a/example/services.yml b/example/services.yml index 0223f6e..8bb25a4 100644 --- a/example/services.yml +++ b/example/services.yml @@ -4,6 +4,9 @@ services: class: PUGX\Godfather\Godfather arguments: [@container, 'godfather'] + godfather.context: + class: PUGX\Godfather\Context\Context + container: class: PUGX\Godfather\Container\SymfonyContainerBuilder arguments: [@service_container] diff --git a/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php b/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php index d86fa8f..ebad069 100644 --- a/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php +++ b/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php @@ -65,18 +65,20 @@ protected function addInstance($name, array $parameters, ContainerBuilder $conta */ protected function addContext(ContainerBuilder $container, $prefix, $name, array $context) { - $fallback = null; $serviceName = $prefix.'.'.$name; - $default = 'godfather.context'; if (isset($context['fallback']) || isset($context['class'])) { - $fallback = $context['fallback']; - $context = new Definition($context['class'], array($fallback)); + + if (!isset($context['class'])) { + $context['class'] = 'PUGX\Godfather\Context\Context'; + } + + $context = new Definition($context['class'], array($context['fallback'])); $container->setDefinition($serviceName, $context); return ; } - $container->setAlias($serviceName, $default); + $container->setAlias($serviceName, 'godfather.context'); } /**