8000 merged branch vicb/sfcc (PR #6148) · symfony/symfony@64b76ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 64b76ba

Browse files
committed
merged branch vicb/sfcc (PR #6148)
This PR was merged into the master branch. Commits ------- 7f16c1f [HttpKernel] Add DI extension configs as ressources when possible Discussion ---------- [HttpKernel] Add DI extension configs as ressources when possible /cc @rdohms @richardmiller --------------------------------------------------------------------------- by vicb at 2012-11-30T11:57:48Z btw @fabpot what about having a base class for `Extension` in the DI ? Would make it easier to re-use it when using standalone components, Di and (the suggested) Config as the greatest part of the class is not HttpKernel specific. --------------------------------------------------------------------------- by fabpot at 2012-12-06T08:47:28Z @vicb your suggestion makes sense. Can you also explain the goal of this PR? --------------------------------------------------------------------------- by vicb at 2012-12-06T09:01:58Z The goal of this PR is to avoid having to sfcc when you modify a DI extension configuration. I think @rdohms got trapped. --------------------------------------------------------------------------- by vicb at 2012-12-06T09:08:08Z see https://twitter.com/rdohms/status/274059267428978688 --------------------------------------------------------------------------- by stof at 2012-12-06T09:20:54Z I thought about it several times but never took time to implement it. It is annoying to have to clear the cache when you modify a default value in the Configuration class. So +1
2 parents 7fec2c9 + 7f16c1f commit 64b76ba

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,12 @@
2222
*/
2323
class Configuration implements ConfigurationInterface
2424
{
25-
private $debug;
26-
27-
/**
28-
* Constructor
29-
*
30-
* @param Boolean $debug Whether to use the debug mode
31-
*/
32-
public function __construct($debug)
33-
{
34-
$this->debug = (Boolean) $debug;
35-
}
36-
3725
/**
3826
* Generates the configuration tree builder.
3927
*
40-
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
28+
* @return TreeBuilder The tree builder
29+
*
30+
* @throws \RuntimeException When using the deprecated 'charset' setting
4131
*/
4232
public function getConfigTreeBuilder()
4333
{
@@ -54,7 +44,7 @@ public function getConfigTreeBuilder()
5444
$message = 'The charset setting is deprecated. Just remove it from your configuration file.';
5545

5646
if ('UTF-8' !== $v) {
57-
$message .= sprintf(' You need to define a getCharset() method in your Application Kernel class that returns "%s".', $v);
47+
$message .= sprintf('You need to define a getCharset() method in your Application Kernel class that returns "%s".', $v);
5848
}
5949

6050
throw new \RuntimeException($message);
@@ -384,7 +374,7 @@ private function addAnnotationsSection(ArrayNodeDefinition $rootNode)
384374
->children()
385375
->scalarNode('cache')->defaultValue('file')->end()
386376
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
387-
->booleanNode('debug')->defaultValue($this->debug)->end()
377+
->booleanNode('debug')->defaultValue('%kernel.debug%')->end()
388378
->end()
389379
->end()
390380
->end()

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ public function load(array $configs, ContainerBuilder $container)
141141
));
142142
}
143143

144-
public function getConfiguration(array $config, ContainerBuilder $container)
145-
{
146-
return new Configuration($container->getParameter('kernel.debug'));
147-
}
148-
149144
/**
150145
* Loads Form configuration.
151146
*

src/Symfony/Component/HttpKernel/DependencyInjection/Extension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpKernel\DependencyInjection;
1313

1414
use Symfony\Component\Config\Definition\Processor;
15+
use Symfony\Component\Config\Resource\FileResource;
1516
use Symfony\Component\Config\Definition\ConfigurationInterface;
1617
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
1718
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
@@ -84,6 +85,8 @@ public function getNamespace()
8485
* This can be overridden in a sub-class to specify the alias manually.
8586
*
8687
* @return string The alias
88+
*
89+
* @throws \BadMethodCallException When the extension name does not follow conventions
8790
*/
8891
public function getAlias()
8992
{
@@ -113,6 +116,9 @@ public function getConfiguration(array $config, ContainerBuilder $container)
113116

114117
$class = $namespace . '\\Configuration';
115118
if (class_exists($class)) {
119+
$r = new \ReflectionClass($class);
120+
$container->addResource(new FileResource($r->getFileName()));
121+
116122
if (!method_exists($class, '__construct')) {
117123
$configuration = new $class();
118124

0 commit comments

Comments
 (0)
0