cleaned up the DI extension loading mechanism
This commit is contained in:
parent
d5954013d5
commit
0fbb1b916b
@ -133,8 +133,6 @@ class DoctrineExtension extends LoaderExtension
|
||||
new Reference(sprintf('doctrine.dbal.%s_connection.event_manager', $name))
|
||||
));
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,8 +253,6 @@ class DoctrineExtension extends LoaderExtension
|
||||
$configuration->getParameter('doctrine.orm.cache_driver')
|
||||
)
|
||||
);
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,8 +60,6 @@ class MongoDBExtension extends LoaderExtension
|
||||
$configuration->setAlias('doctrine.odm.mongodb.'.$key, 'doctrine.odm.mongodb.'.$key.'.'.$config[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,8 +166,6 @@ class WebExtension extends LoaderExtension
|
||||
$configuration->getDefinition('validator')->clearAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,8 +219,6 @@ class WebExtension extends LoaderExtension
|
||||
$configuration->setDefinition('templating.loader', $configuration->getDefinition('templating.loader.cache'));
|
||||
$configuration->setParameter('templating.loader.cache.path', $config['cache']);
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,8 +43,6 @@ class PropelExtension extends LoaderExtension
|
||||
if (isset($config['phing_path'])) {
|
||||
$configuration->setParameter('propel.phing_path', $config['phing_path']);
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,8 +116,6 @@ class PropelExtension extends LoaderExtension
|
||||
}
|
||||
|
||||
$configuration->getDefinition('propel.configuration')->setArguments(array($c));
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,8 +106,6 @@ class SwiftMailerExtension extends LoaderExtension
|
||||
if (isset($config['disable_delivery']) && $config['disable_delivery']) {
|
||||
$configuration->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.blackhole')));
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,6 @@ class TwigExtension extends LoaderExtension
|
||||
}
|
||||
|
||||
$configuration->setParameter('twig.options', array_replace($configuration->getParameter('twig.options'), $config));
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,8 +55,6 @@ class ZendExtension extends LoaderExtension
|
||||
if (isset($config['path'])) {
|
||||
$configuration->setParameter('zend.logger.path', $config['path']);
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,7 @@ class BuilderConfiguration
|
||||
$this->extensions[$namespace]->addResource(new FileResource($r->getFileName()));
|
||||
}
|
||||
|
||||
$this->extensions[$namespace] = $extension->load($tag, $values, $this->extensions[$namespace]);
|
||||
$extension->load($tag, $values, $this->extensions[$namespace]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -42,8 +42,6 @@ abstract class LoaderExtension implements LoaderExtensionInterface
|
||||
* @param array $config An array of configuration values
|
||||
* @param BuilderConfiguration $configuration A BuilderConfiguration instance
|
||||
*
|
||||
* @return BuilderConfiguration A BuilderConfiguration instance
|
||||
*
|
||||
* @throws \InvalidArgumentException When provided tag is not defined in this extension
|
||||
*/
|
||||
public function load($tag, array $config, BuilderConfiguration $configuration)
|
||||
@ -52,6 +50,6 @@ abstract class LoaderExtension implements LoaderExtensionInterface
|
||||
throw new \InvalidArgumentException(sprintf('The tag "%s:%s" is not defined in the "%s" extension.', $this->getAlias(), $tag, $this->getAlias()));
|
||||
}
|
||||
|
||||
return $this->$method($config, $configuration);
|
||||
$this->$method($config, $configuration);
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,8 @@ use Symfony\Components\DependencyInjection\BuilderConfiguration;
|
||||
*/
|
||||
class KernelExtension extends LoaderExtension
|
||||
{
|
||||
public function testLoad($config)
|
||||
public function testLoad($config, BuilderConfiguration $configuration)
|
||||
{
|
||||
$configuration = new BuilderConfiguration();
|
||||
|
||||
$loader = new XmlFileLoader(array(__DIR__.'/../Resources/config', __DIR__.'/Resources/config'));
|
||||
$configuration->merge($loader->load('test.xml'));
|
||||
$configuration->setParameter('kernel.include_core_classes', false);
|
||||
@ -76,10 +74,8 @@ class KernelExtension extends LoaderExtension
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
public function configLoad($config)
|
||||
public function configLoad($config, BuilderConfiguration $configuration)
|
||||
{
|
||||
$configuration = new BuilderConfiguration();
|
||||
|
||||
if (isset($config['charset'])) {
|
||||
$configuration->setParameter('kernel.charset', $config['charset']);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class LoaderExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('The tag "project:foo" is not defined in the "project" extension.', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag does not exist');
|
||||
}
|
||||
|
||||
$config = $extension->load('bar', array('foo' => 'bar'), new BuilderConfiguration());
|
||||
$extension->load('bar', array('foo' => 'bar'), $config = new BuilderConfiguration());
|
||||
$this->assertEquals(array('project.parameter.bar' => 'bar', 'project.parameter.foo' => 'bar'), $config->getParameterBag()->all(), '->load() calls the method tied to the given tag');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user