[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
|
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.
|
* 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()
|
public function getConfigTreeBuilder()
|
||||||
{
|
{
|
||||||
@ -54,7 +44,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
$message = 'The charset setting is deprecated. Just remove it from your configuration file.';
|
$message = 'The charset setting is deprecated. Just remove it from your configuration file.';
|
||||||
|
|
||||||
if ('UTF-8' !== $v) {
|
if ('UTF-8' !== $v) {
|
||||||
$message .= sprintf(' You need to define a getCharset() method in your Application Kernel class that returns "%s".', $v);
|
$message .= sprintf('You need to define a getCharset() method in your Application Kernel class that returns "%s".', $v);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException($message);
|
throw new \RuntimeException($message);
|
||||||
@ -384,7 +374,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->children()
|
->children()
|
||||||
->scalarNode('cache')->defaultValue('file')->end()
|
->scalarNode('cache')->defaultValue('file')->end()
|
||||||
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->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()
|
->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.
|
* Loads Form configuration.
|
||||||
*
|
*
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\HttpKernel\DependencyInjection;
|
namespace Symfony\Component\HttpKernel\DependencyInjection;
|
||||||
|
|
||||||
use Symfony\Component\Config\Definition\Processor;
|
use Symfony\Component\Config\Definition\Processor;
|
||||||
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||||
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
|
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.
|
* This can be overridden in a sub-class to specify the alias manually.
|
||||||
*
|
*
|
||||||
* @return string The alias
|
* @return string The alias
|
||||||
|
*
|
||||||
|
* @throws \BadMethodCallException When the extension name does not follow conventions
|
||||||
*/
|
*/
|
||||||
public function getAlias()
|
public function getAlias()
|
||||||
{
|
{
|
||||||
@ -113,6 +116,9 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
|||||||
|
|
||||||
$class = $namespace . '\\Configuration';
|
$class = $namespace . '\\Configuration';
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
|
$r = new \ReflectionClass($class);
|
||||||
|
$container->addResource(new FileResource($r->getFileName()));
|
||||||
|
|
||||||
if (!method_exists($class, '__construct')) {
|
if (!method_exists($class, '__construct')) {
|
||||||
$configuration = new $class();
|
$configuration = new $class();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user