[HttpKernel] Add DI extension configs as ressources when possible
This commit is contained in:
parent
50a62da114
commit
7f16c1f5bc
@ -22,22 +22,12 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
private $debug;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Boolean $debug Whether to use the debug mode
|
||||
*/
|
||||
public function __construct($debug)
|
||||
{
|
||||
$this->debug = (Boolean) $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the configuration tree builder.
|
||||
*
|
||||
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
|
||||
* @return TreeBuilder The tree builder
|
||||
*
|
||||
* @throws \RuntimeException When using the deprecated 'charset' setting
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
@ -384,7 +374,7 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->scalarNode('cache')->defaultValue('file')->end()
|
||||
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
|
||||
->booleanNode('debug')->defaultValue($this->debug)->end()
|
||||
->booleanNode('debug')->defaultValue('%kernel.debug%')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -141,11 +141,6 @@ class FrameworkExtension extends Extension
|
||||
));
|
||||
}
|
||||
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
return new Configuration($container->getParameter('kernel.debug'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads Form configuration.
|
||||
*
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\HttpKernel\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
|
||||
@ -84,6 +85,8 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
* This can be overridden in a sub-class to specify the alias manually.
|
||||
*
|
||||
* @return string The alias
|
||||
*
|
||||
* @throws \BadMethodCallException When the extension name does not follow conventions
|
||||
*/
|
||||
public function getAlias()
|
||||
{
|
||||
@ -113,6 +116,9 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
|
||||
$class = $namespace . '\\Configuration';
|
||||
if (class_exists($class)) {
|
||||
$r = new \ReflectionClass($class);
|
||||
$container->addResource(new FileResource($r->getFileName()));
|
||||
|
||||
if (!method_exists($class, '__construct')) {
|
||||
$configuration = new $class();
|
||||
|
||||
|
Reference in New Issue
Block a user