From bfb0f094f42f10e4781623a0d98c06704bb7eea1 Mon Sep 17 00:00:00 2001 From: Kris Wallsmith Date: Wed, 13 Apr 2011 05:13:04 -0700 Subject: [PATCH] [AsseticBundle] updated bundle node to match others, cleaned up validation --- UPDATE.md | 14 ++++++++++++++ .../DependencyInjection/AsseticExtension.php | 7 +------ .../DependencyInjection/Configuration.php | 10 +++------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/UPDATE.md b/UPDATE.md index b8d79b3be0..0fdc4f4caf 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -6,6 +6,20 @@ one. It only discusses changes that need to be done when using the "public" API of the framework. If you "hack" the core, you should probably follow the timeline closely anyway. +PR11 to PR12 +------------ + +* AsseticBundle's XML `bundle` node has been normalized to match other similar + nodes + + Before: + + + + After: + + MyBundle + PR10 to PR11 ------------ diff --git a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php index 1540343eca..0b4e5faac1 100644 --- a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php +++ b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php @@ -115,12 +115,7 @@ class AsseticExtension extends Extension static protected function registerFormulaResources(ContainerBuilder $container, array $bundles) { $map = $container->getParameter('kernel.bundles'); - - if ($diff = array_diff($bundles, array_keys($map))) { - throw new \InvalidArgumentException(sprintf('The following bundles are not registered: "%s"', implode('", "', $diff))); - } - - $am = $container->getDefinition('assetic.asset_manager'); + $am = $container->getDefinition('assetic.asset_manager'); // bundle views/ directories and kernel overrides foreach ($bundles as $name) { diff --git a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php index 83b52d9949..d0d2061276 100644 --- a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php @@ -66,14 +66,10 @@ class Configuration implements ConfigurationInterface ->arrayNode('bundles') ->defaultValue($this->bundles) ->requiresAtLeastOneElement() - ->beforeNormalization() - ->ifTrue(function($v) { return !is_array($v); }) - ->then(function($v) { return array($v); }) - ->end() ->prototype('scalar') - ->beforeNormalization() - ->ifTrue(function($v) { return is_array($v) && isset($v['name']); }) - ->then(function($v) { return $v['name']; }) + ->validate() + ->ifNotInArray($this->bundles) + ->thenInvalid('%s is not a valid bundle.') ->end() ->end() ->end()