From 837ea0156ca926f13ca8699254af7cccdbc0aeb2 Mon Sep 17 00:00:00 2001 From: liuggio Date: Tue, 14 Jan 2014 16:16:35 +0100 Subject: [PATCH] fixed sandbox --- example/services.yml | 3 +++ .../DependencyInjection/GodfatherExtension.php | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) 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'); } /**