File tree 1 file changed +35
-0
lines changed
Filter options
src/Symfony/Component/OptionsResolver
1 file changed +35
-0
lines changed
Original file line number Diff line number Diff line change @@ -718,6 +718,41 @@ public function addAllowedTypes($option, $allowedTypes)
718
718
return $ this ;
719
719
}
720
720
721
+ /**
722
+ * Adds allowed types for one or more options.
723
+ *
724
+ * If a nested option name is passed it will apply to all nested options.
725
+ *
726
+ * Any type for which a corresponding is_<type>() function exists is
727
+ * acceptable. Additionally, fully-qualified class or interface names may
728
+ * be passed.
729
+ *
730
+ * @param string|string[] $options One or more option names
731
+ * @param string|string[] $allowedTypes One or more accepted types
732
+ *
733
+ * @return OptionsResolver This instance
734
+ *
735
+ * @throws UndefinedOptionsException If an option is undefined
736
+ * @throws AccessException If called from a lazy option or normalizer
737
+ */
738
+ public function addAllowTypesForAll ($ options , $ allowedTypes )
739
+ {
740
+ if ($ this ->locked ) {
741
+ throw new AccessException ('Allowed types cannot be added from a lazy option or normalizer. ' );
742
+ }
743
+
744
+ foreach ((array ) $ options as $ option ) {
745
+ // Not supported for nested options
746
+ if ($ this ->isNested ($ option )) {
747
+ $ this ->addAllowTypesForAll ($ this ->nested [$ option ]->getDefinedOptions (), $ allowedTypes );
748
+ }
749
+
750
+ $ this ->addAllowedTypes ($ option , $ allowedTypes );
751
+ }
752
+
753
+ return $ this ;
754
+ }
755
+
721
756
/**
722
757
* Removes the option with the given name.
723
758
*
You can’t perform that action at this time.
0 commit comments