diff --git a/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php b/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php index ebad069..3e3768e 100644 --- a/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php +++ b/sf2-bundle/PUGX/GodfatherBundle/DependencyInjection/GodfatherExtension.php @@ -2,6 +2,7 @@ namespace PUGX\GodfatherBundle\DependencyInjection; +use PUGX\Godfather\ServiceNameConverter; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Definition; @@ -16,6 +17,16 @@ */ class GodfatherExtension extends Extension { + /** + * @var \PUGX\Godfather\ServiceNameConverter + */ + protected $nameConverter; + + public function __construct(ServiceNameConverter $serviceNameConverter = null) + { + $this->nameConverter = $serviceNameConverter ?: new ServiceNameConverter(); + } + /** * {@inheritDoc} */ @@ -65,6 +76,8 @@ protected function addInstance($name, array $parameters, ContainerBuilder $conta */ protected function addContext(ContainerBuilder $container, $prefix, $name, array $context) { + $name = $this->nameConverter->serviceNameConverter($name); + $serviceName = $prefix.'.'.$name; if (isset($context['fallback']) || isset($context['class'])) { @@ -129,7 +142,7 @@ protected function createGodFatherDefinition(ContainerBuilder $container, $prefi */ protected function createServiceContainerDefinition(ContainerBuilder $container, $prefix) { - $container = new Definition('%godfather.class%'); + $container = new Definition('%godfather.class%'); return new Definition('%godfather.class%', array($container, $prefix)); } diff --git a/sf2-bundle/PUGX/GodfatherBundle/Tests/DependencyInjection/GodfatherExtensionTest.php b/sf2-bundle/PUGX/GodfatherBundle/Tests/DependencyInjection/GodfatherExtensionTest.php index a506db0..782ebb1 100755 --- a/sf2-bundle/PUGX/GodfatherBundle/Tests/DependencyInjection/GodfatherExtensionTest.php +++ b/sf2-bundle/PUGX/GodfatherBundle/Tests/DependencyInjection/GodfatherExtensionTest.php @@ -64,6 +64,29 @@ public function testMultipleInstances() $this->assertTrue($container->hasDefinition('godfather.instance1.manager')); } + public function testInstanceName() + { + $container = new ContainerBuilder(); + $loader = new GodfatherExtension(); + $loader->load(array($this->getConfigWithCamelCaseNamedContext()), $container); + + $this->assertTrue($container->hasAlias('godfather.object_manager')); + } + + + + protected function getConfigWithCamelCaseNamedContext() + { + $yaml = <<parse($yaml); + } + protected function getFullConfigWithMultipleInstances() { $yaml = <<