From 3fbe2944617369bd302e049d6d586b92d445bc81 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 1 Mar 2010 12:30:23 +0100 Subject: [PATCH] [DoctrineBundle] removed the need to pass the container to the extension (which is dangerous) --- src/Symfony/Framework/DoctrineBundle/Bundle.php | 2 +- .../DependencyInjection/DoctrineExtension.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Framework/DoctrineBundle/Bundle.php b/src/Symfony/Framework/DoctrineBundle/Bundle.php index 749c3cac84..7b5baa0bee 100644 --- a/src/Symfony/Framework/DoctrineBundle/Bundle.php +++ b/src/Symfony/Framework/DoctrineBundle/Bundle.php @@ -28,7 +28,7 @@ class Bundle extends BaseBundle { public function buildContainer(ContainerInterface $container) { - Loader::registerExtension(new DoctrineExtension($container)); + Loader::registerExtension(new DoctrineExtension($container->getParameter('kernel.bundle_dirs'), $container->getParameter('kernel.bundles'))); $metadataDirs = array(); $entityDirs = array(); diff --git a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php index cbadc847c5..d7e6824465 100644 --- a/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php +++ b/src/Symfony/Framework/DoctrineBundle/DependencyInjection/DoctrineExtension.php @@ -7,7 +7,6 @@ use Symfony\Components\DependencyInjection\Loader\XmlFileLoader; use Symfony\Components\DependencyInjection\BuilderConfiguration; use Symfony\Components\DependencyInjection\Definition; use Symfony\Components\DependencyInjection\Reference; -use Symfony\Components\DependencyInjection\Container; /* * This file is part of the symfony framework. @@ -33,10 +32,13 @@ class DoctrineExtension extends LoaderExtension ); protected $alias; + protected $bundleDirs; + protected $bundles; - public function __construct(Container $container) + public function __construct(array $bundleDirs, array $bundles) { - $this->container = $container; + $this->bundleDirs = $bundleDirs; + $this->bundles = $bundles; } public function setAlias($alias) @@ -197,8 +199,8 @@ class DoctrineExtension extends LoaderExtension // configure metadata driver for each bundle based on the type of mapping files found $mappingDriverDef = new Definition('Doctrine\ORM\Mapping\Driver\DriverChain'); $bundleEntityMappings = array(); - $bundleDirs = $this->container->getParameter('kernel.bundle_dirs'); - foreach ($this->container->getParameter('kernel.bundles') as $className) + $bundleDirs = $this->bundleDirs; + foreach ($this->bundles as $className) { $tmp = dirname(str_replace('\\', '/', $className)); $namespace = str_replace('/', '\\', dirname($tmp));