Skip to content

Commit

Permalink
moved DI extensions classes to their own sub-namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jul 16, 2010
1 parent 47fd5e8 commit 2a051b5
Show file tree
Hide file tree
Showing 37 changed files with 318 additions and 320 deletions.
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Bundle\DoctrineBundle\DependencyInjection;

use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
use Symfony\Components\DependencyInjection\Extension\Extension;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\Definition;
Expand All @@ -24,7 +24,7 @@
* @subpackage Bundle_DoctrineBundle
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class DoctrineExtension extends LoaderExtension
class DoctrineExtension extends Extension
{
protected $resources;
protected $alias;
Expand Down Expand Up @@ -59,8 +59,8 @@ public function setAlias($alias)
public function dbalLoad($config, ContainerBuilder $container)
{
if (!$container->hasDefinition('doctrine.dbal.logger')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['dbal']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['dbal']);
}

$defaultConnection = array(
Expand Down Expand Up @@ -142,8 +142,8 @@ public function dbalLoad($config, ContainerBuilder $container)
*/
public function ormLoad($config, ContainerBuilder $container)
{
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['orm']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['orm']);

if (isset($config['default_entity_manager'])) {
$container->getParameter('doctrine.orm.default_entity_manager', $config['default_entity_manager']);
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php
Expand Up @@ -4,6 +4,7 @@

use Symfony\Framework\Bundle\Bundle;
use Symfony\Components\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\Loader\Loader;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
Expand Down Expand Up @@ -36,7 +37,7 @@ class DoctrineBundle extends Bundle
*/
public function buildContainer(ParameterBagInterface $parameterBag)
{
Loader::registerExtension(new DoctrineExtension($parameterBag->get('kernel.bundle_dirs'), $parameterBag->get('kernel.bundles')));
ContainerBuilder::registerExtension(new DoctrineExtension($parameterBag->get('kernel.bundle_dirs'), $parameterBag->get('kernel.bundles')));

$metadataDirs = array();
$entityDirs = array();
Expand Down
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Bundle\DoctrineMongoDBBundle\DependencyInjection;

use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
use Symfony\Components\DependencyInjection\Extension\Extension;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\Reference;
Expand All @@ -18,7 +18,7 @@
*
* @todo Add support for multiple document managers
*/
class MongoDBExtension extends LoaderExtension
class MongoDBExtension extends Extension
{
protected $bundles;
protected $resources = array(
Expand All @@ -38,8 +38,8 @@ public function __construct(array $bundles)
*/
public function mongodbLoad($config, ContainerBuilder $container)
{
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['mongodb']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['mongodb']);

if (!$container->hasDefinition('doctrine.odm.mongodb.document_manager')) {

Expand Down
Expand Up @@ -25,6 +25,6 @@ class DoctrineMongoDBBundle extends Bundle
*/
public function buildContainer(ParameterBagInterface $parameterBag)
{
Loader::registerExtension(new MongoDBExtension($parameterBag->get('kernel.bundles')));
ContainerBuilder::registerExtension(new MongoDBExtension($parameterBag->get('kernel.bundles')));
}
}
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
use Symfony\Components\DependencyInjection\Extension\Extension;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Components\DependencyInjection\Resource\FileResource;
use Symfony\Components\DependencyInjection\ContainerBuilder;
Expand All @@ -25,7 +25,7 @@
* @subpackage Bundle_FrameworkBundle
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class WebExtension extends LoaderExtension
class WebExtension extends Extension
{
protected $resources = array(
'templating' => 'templating.xml',
Expand Down Expand Up @@ -53,8 +53,8 @@ public function __construct(array $bundleDirs, array $bundles)
public function configLoad($config, ContainerBuilder $container)
{
if (!$container->hasDefinition('controller_manager')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['web']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['web']);
}

if (isset($config['ide']) && 'textmate' === $config['ide']) {
Expand All @@ -68,9 +68,9 @@ public function configLoad($config, ContainerBuilder $container)
if (isset($config['profiler'])) {
if ($config['profiler']) {
if (!$container->hasDefinition('profiler')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load('profiling.xml'));
$container->merge($loader->load('collectors.xml'));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load('profiling.xml');
$loader->load('collectors.xml');
}
} elseif ($container->hasDefinition('profiler')) {
$container->getDefinition('profiling')->clearAnnotations();
Expand All @@ -81,8 +81,8 @@ public function configLoad($config, ContainerBuilder $container)
if (isset($config['toolbar'])) {
if ($config['toolbar']) {
if (!$container->hasDefinition('debug.toolbar')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load('toolbar.xml'));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load('toolbar.xml');
}
} elseif ($container->hasDefinition('debug.toolbar')) {
$container->getDefinition('debug.toolbar')->clearAnnotations();
Expand All @@ -92,8 +92,8 @@ public function configLoad($config, ContainerBuilder $container)
if (isset($config['validation']['enabled'])) {
if ($config['validation']['enabled']) {
if (!$container->hasDefinition('validator')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['validation']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['validation']);
}

$xmlMappingFiles = array();
Expand Down Expand Up @@ -175,8 +175,8 @@ public function configLoad($config, ContainerBuilder $container)
public function templatingLoad($config, ContainerBuilder $container)
{
if (!$container->hasDefinition('templating')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['templating']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['templating']);
}

if (array_key_exists('escaping', $config)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Expand Up @@ -36,7 +36,7 @@ class FrameworkBundle extends Bundle
*/
public function buildContainer(ParameterBagInterface $parameterBag)
{
Loader::registerExtension(new WebExtension($parameterBag->get('kernel.bundle_dirs'), $parameterBag->get('kernel.bundles')));
ContainerBuilder::registerExtension(new WebExtension($parameterBag->get('kernel.bundle_dirs'), $parameterBag->get('kernel.bundles')));

$dirs = array('%kernel.root_dir%/views/%%bundle%%/%%controller%%/%%name%%%%format%%.%%renderer%%');
foreach ($parameterBag->get('kernel.bundle_dirs') as $dir) {
Expand All @@ -46,8 +46,8 @@ public function buildContainer(ParameterBagInterface $parameterBag)

$container = new ContainerBuilder();
if ($parameterBag->get('kernel.debug')) {
$loader = new XmlFileLoader(__DIR__.'/Resources/config');
$container->merge($loader->load('debug.xml'));
$loader = new XmlFileLoader($container, __DIR__.'/Resources/config');
$loader->load('debug.xml');
}

return $container;
Expand Down
Expand Up @@ -2,13 +2,13 @@

namespace Symfony\Bundle\PropelBundle\DependencyInjection;

use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
use Symfony\Components\DependencyInjection\Extension\Extension;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\Definition;
use Symfony\Components\DependencyInjection\Reference;

class PropelExtension extends LoaderExtension
class PropelExtension extends Extension
{
protected $resources = array(
'propel' => 'propel.xml',
Expand All @@ -23,8 +23,8 @@ class PropelExtension extends LoaderExtension
public function configLoad($config, ContainerBuilder $container)
{
if (!$container->hasDefinition('propel')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['propel']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['propel']);
}

if (!$container->hasParameter('propel.path')) {
Expand Down Expand Up @@ -53,8 +53,8 @@ public function configLoad($config, ContainerBuilder $container)
public function dbalLoad($config, ContainerBuilder $container)
{
if (!$container->hasDefinition('propel')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['propel']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['propel']);
}

$defaultConnection = array(
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/PropelBundle/PropelBundle.php
Expand Up @@ -20,7 +20,7 @@ class PropelBundle extends Bundle
*/
public function buildContainer(ParameterBagInterface $parameterBag)
{
Loader::registerExtension(new PropelExtension());
ContainerBuilder::registerExtension(new PropelExtension());
}

public function boot(ContainerInterface $container)
Expand Down
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection;

use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
use Symfony\Components\DependencyInjection\Extension\Extension;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\Reference;
Expand All @@ -23,7 +23,7 @@
* @subpackage Bundle_SwiftmailerBundle
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class SwiftMailerExtension extends LoaderExtension
class SwiftMailerExtension extends Extension
{
protected $resources = array(
'mailer' => 'swiftmailer.xml',
Expand All @@ -46,8 +46,8 @@ class SwiftMailerExtension extends LoaderExtension
public function mailerLoad($config, ContainerBuilder $container)
{
if (!$container->hasDefinition('swiftmailer.mailer')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['mailer']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['mailer']);
$container->setAlias('mailer', 'swiftmailer.mailer');
}

Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/SwiftmailerBundle/SwiftmailerBundle.php
Expand Up @@ -4,6 +4,7 @@

use Symfony\Framework\Bundle\Bundle;
use Symfony\Components\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\Loader\Loader;
use Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerExtension;

Expand Down Expand Up @@ -34,6 +35,6 @@ class SwiftmailerBundle extends Bundle
*/
public function buildContainer(ParameterBagInterface $parameterBag)
{
Loader::registerExtension(new SwiftmailerExtension());
ContainerBuilder::registerExtension(new SwiftmailerExtension());
}
}
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Bundle\TwigBundle\DependencyInjection;

use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
use Symfony\Components\DependencyInjection\Extension\Extension;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Components\DependencyInjection\ContainerBuilder;

Expand All @@ -22,7 +22,7 @@
* @subpackage Bundle_TwigBundle
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class TwigExtension extends LoaderExtension
class TwigExtension extends Extension
{
/**
* Loads the Twig configuration.
Expand All @@ -33,8 +33,8 @@ class TwigExtension extends LoaderExtension
public function configLoad($config, ContainerBuilder $container)
{
if (!$container->hasDefinition('twig')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load('twig.xml'));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load('twig.xml');
}

$container->setParameter('twig.options', array_replace($container->getParameter('twig.options'), $config));
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/TwigBundle.php
Expand Up @@ -36,6 +36,6 @@ class TwigBundle extends Bundle
*/
public function buildContainer(ParameterBagInterface $parameterBag)
{
Loader::registerExtension(new TwigExtension());
ContainerBuilder::registerExtension(new TwigExtension());
}
}
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Bundle\ZendBundle\DependencyInjection;

use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
use Symfony\Components\DependencyInjection\Extension\Extension;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Components\DependencyInjection\ContainerBuilder;

Expand All @@ -22,7 +22,7 @@
* @subpackage Bundle_ZendBundle
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class ZendExtension extends LoaderExtension
class ZendExtension extends Extension
{
protected $resources = array(
'logger' => 'logger.xml',
Expand All @@ -41,8 +41,8 @@ class ZendExtension extends LoaderExtension
public function loggerLoad($config, ContainerBuilder $container)
{
if (!$container->hasDefinition('zend.logger')) {
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$container->merge($loader->load($this->resources['logger']));
$loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
$loader->load($this->resources['logger']);
$container->setAlias('logger', 'zend.logger');
}

Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/ZendBundle/ZendBundle.php
Expand Up @@ -6,6 +6,7 @@
use Symfony\Components\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Components\DependencyInjection\Reference;
use Symfony\Components\DependencyInjection\Loader\Loader;
use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Bundle\ZendBundle\DependencyInjection\ZendExtension;

/*
Expand Down Expand Up @@ -35,6 +36,6 @@ class ZendBundle extends Bundle
*/
public function buildContainer(ParameterBagInterface $parameterBag)
{
Loader::registerExtension(new ZendExtension());
ContainerBuilder::registerExtension(new ZendExtension());
}
}

0 comments on commit 2a051b5

Please sign in to comment.