| Conditions | 2 |
| Paths | 1 |
| Total Lines | 86 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 28 | public function getConfigTreeBuilder() |
||
| 29 | { |
||
| 30 | $treeBuilder = new TreeBuilder('sonata_translation'); |
||
| 31 | |||
| 32 | $rootNode = $treeBuilder->getRootNode(); |
||
| 33 | |||
| 34 | $rootNode |
||
| 35 | ->children() |
||
| 36 | ->arrayNode('locales') |
||
| 37 | ->info('The list of your frontend locales in which your models will be translatable.') |
||
| 38 | ->requiresAtLeastOneElement() |
||
| 39 | ->prototype('scalar')->end() |
||
| 40 | ->end() |
||
| 41 | ->scalarNode('default_locale') |
||
| 42 | ->defaultValue('en') |
||
| 43 | ->info('The frontend locale that is used by default.') |
||
| 44 | ->end() |
||
| 45 | ->enumNode('default_filter_mode') |
||
| 46 | ->values(TranslationFilterMode::AVAILABLE_FILTER_TYPES) |
||
| 47 | ->defaultValue(TranslationFilterMode::GEDMO) |
||
| 48 | ->info('The filter mode that is used by default.') |
||
| 49 | ->end() |
||
| 50 | ->arrayNode('gedmo') |
||
| 51 | ->canBeEnabled() |
||
| 52 | ->children() |
||
| 53 | ->arrayNode('implements') |
||
| 54 | ->requiresAtLeastOneElement() |
||
| 55 | ->prototype('scalar')->end() |
||
| 56 | ->end() |
||
| 57 | ->arrayNode('instanceof') |
||
| 58 | ->requiresAtLeastOneElement() |
||
| 59 | ->prototype('scalar')->end() |
||
| 60 | ->end() |
||
| 61 | ->end() |
||
| 62 | ->end() |
||
| 63 | ->arrayNode('knplabs') |
||
| 64 | ->canBeEnabled() |
||
| 65 | ->children() |
||
| 66 | ->arrayNode('implements') |
||
| 67 | ->requiresAtLeastOneElement() |
||
| 68 | ->prototype('scalar')->end() |
||
| 69 | ->end() |
||
| 70 | ->arrayNode('instanceof') |
||
| 71 | ->requiresAtLeastOneElement() |
||
| 72 | ->prototype('scalar')->end() |
||
| 73 | ->end() |
||
| 74 | ->end() |
||
| 75 | ->end() |
||
| 76 | ->arrayNode('phpcr') |
||
| 77 | ->canBeEnabled() |
||
| 78 | ->children() |
||
| 79 | ->arrayNode('implements') |
||
| 80 | ->requiresAtLeastOneElement() |
||
| 81 | ->prototype('scalar')->end() |
||
| 82 | ->end() |
||
| 83 | ->arrayNode('instanceof') |
||
| 84 | ->requiresAtLeastOneElement() |
||
| 85 | ->prototype('scalar')->end() |
||
| 86 | ->end() |
||
| 87 | ->end() |
||
| 88 | ->end() |
||
| 89 | ->booleanNode('locale_switcher') |
||
| 90 | ->info('Enable the global locale switcher services.') |
||
| 91 | ->defaultFalse() |
||
| 92 | ->end() |
||
| 93 | // NEXT_MAJOR: Fix locale to country flag mapping OR remove country flags entirely |
||
| 94 | ->booleanNode('locale_switcher_show_country_flags') |
||
| 95 | ->info('Whether the language switcher should show languages as flags') |
||
| 96 | ->defaultTrue() |
||
| 97 | ->end() |
||
| 98 | ->end() |
||
| 99 | ->beforeNormalization() |
||
| 100 | ->ifTrue(static function ($v) {return !isset($v['locale_switcher_show_country_flags']) || true === $v['locale_switcher_show_country_flags']; }) |
||
| 101 | ->then(static function ($v) { |
||
| 102 | @trigger_error(sprintf( |
||
|
|
|||
| 103 | 'Showing the country flags is deprecated. The flags will be removed in the next major version. Please set "%s" to false to avoid this message.', |
||
| 104 | 'sonata_translation.locale_switcher_show_country_flags' |
||
| 105 | ), E_USER_DEPRECATED); |
||
| 106 | $v['locale_switcher_show_country_flags'] = $v['locale_switcher_show_country_flags'] ?? true; |
||
| 107 | |||
| 108 | return $v; |
||
| 109 | }) |
||
| 110 | ->end(); |
||
| 111 | |||
| 112 | return $treeBuilder; |
||
| 113 | } |
||
| 114 | } |
||
| 115 |
If you suppress an error, we recommend checking for the error condition explicitly: