فهرست منبع

Merge remote branch 'kriswallsmith/assetic/config-tweak'

* kriswallsmith/assetic/config-tweak:
  [AsseticBundle] updated bundle node to match others, cleaned up validation
Fabien Potencier 14 سال پیش
والد
کامیت
3d093c161b

+ 14 - 0
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
 API of the framework. If you "hack" the core, you should probably follow the
 timeline closely anyway.
 timeline closely anyway.
 
 
+PR11 to PR12
+------------
+
+* AsseticBundle's XML `bundle` node has been normalized to match other similar
+  nodes
+
+  Before:
+
+        <bundle name="MyBundle" />
+
+  After:
+
+        <bundle>MyBundle</bundle>
+
 PR10 to PR11
 PR10 to PR11
 ------------
 ------------
 
 

+ 1 - 6
src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php

@@ -115,12 +115,7 @@ class AsseticExtension extends Extension
     static protected function registerFormulaResources(ContainerBuilder $container, array $bundles)
     static protected function registerFormulaResources(ContainerBuilder $container, array $bundles)
     {
     {
         $map = $container->getParameter('kernel.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
         // bundle views/ directories and kernel overrides
         foreach ($bundles as $name) {
         foreach ($bundles as $name) {

+ 3 - 7
src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php

@@ -66,14 +66,10 @@ class Configuration implements ConfigurationInterface
                 ->arrayNode('bundles')
                 ->arrayNode('bundles')
                     ->defaultValue($this->bundles)
                     ->defaultValue($this->bundles)
                     ->requiresAtLeastOneElement()
                     ->requiresAtLeastOneElement()
-                    ->beforeNormalization()
-                        ->ifTrue(function($v) { return !is_array($v); })
-                        ->then(function($v) { return array($v); })
-                    ->end()
                     ->prototype('scalar')
                     ->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()
                     ->end()
                 ->end()
                 ->end()