Преглед изворни кода

merged branch mvrhov/patch-1 (PR #1902)

Commits
-------

e78bc32 Fixed: Notice: Undefined index: enable_annotations in ...

Discussion
----------

Fixed: Notice: Undefined index: enable_annotations in ...

---------------------------------------------------------------------------

by stloyd at 2011/08/04 03:57:49 -0700

IMO `isset()` should be good enough here.

---------------------------------------------------------------------------

by stof at 2011/08/04 04:18:20 -0700

I don't see how such a notice could occur. There is a default value for this node so as soon as the validation node exists, there will be a value for this node. Could you give an example of configuration that causes the notice ?

---------------------------------------------------------------------------

by mvrhov at 2011/08/04 04:23:33 -0700

I don't have any validation node set up in my config in such a case it seems that sub nodes doesn't get build. So it seems that I found a bug in config builder.

---------------------------------------------------------------------------

by stof at 2011/08/04 04:54:05 -0700

This is in fact due to a hackish stuff in the DI extension. It changes the configuration after using the Config component to merge them in the case where you enable the forms without enabling the validator, to force enabling it.
Fabien Potencier пре 13 година
родитељ
комит
db713ea34d

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

@@ -524,7 +524,7 @@ class FrameworkExtension extends Extension
         $container->setParameter('validator.mapping.loader.xml_files_loader.mapping_files', $this->getValidatorXmlMappingFiles($container));
         $container->setParameter('validator.mapping.loader.yaml_files_loader.mapping_files', $this->getValidatorYamlMappingFiles($container));
 
-        if ($config['enable_annotations']) {
+        if (array_key_exists('enable_annotations', $config) && $config['enable_annotations']) {
             $loaderChain = $container->getDefinition('validator.mapping.loader.loader_chain');
             $arguments = $loaderChain->getArguments();
             array_unshift($arguments[0], new Reference('validator.mapping.loader.annotation_loader'));