| Conditions | 7 |
| Paths | 1 |
| Total Lines | 152 |
| Code Lines | 143 |
| 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 |
||
| 23 | public function getConfigTreeBuilder(): TreeBuilder |
||
| 24 | { |
||
| 25 | $treeBuilder = new TreeBuilder('zikula_theme'); |
||
| 26 | |||
| 27 | $treeBuilder->getRootNode() |
||
| 28 | ->children() |
||
| 29 | ->arrayNode('user_dashboard') |
||
| 30 | ->info('Dashboard for main site.') |
||
| 31 | ->addDefaultsIfNotSet() |
||
| 32 | ->children() |
||
| 33 | ->scalarNode('class') |
||
| 34 | ->info('FQCN of the dashboard controller used for the user dashboard.') |
||
| 35 | ->defaultValue(UserDashboardController::class) |
||
| 36 | ->end() |
||
| 37 | ->arrayNode('view') |
||
|
|
|||
| 38 | ->info('Default view option.') |
||
| 39 | ->addDefaultsIfNotSet() |
||
| 40 | ->children() |
||
| 41 | ->booleanNode('content_maximized') |
||
| 42 | ->info('Whether the page content should span the entire browser width, instead of a defined max width.') |
||
| 43 | ->defaultTrue() |
||
| 44 | ->end() |
||
| 45 | ->booleanNode('sidebar_minimized') |
||
| 46 | ->info('Whether the sidebar (which contains the main menu) should be displayed as a narrow column instead of the expanded design.') |
||
| 47 | ->defaultFalse() |
||
| 48 | ->end() |
||
| 49 | ->end() |
||
| 50 | ->end() |
||
| 51 | ->arrayNode('content') |
||
| 52 | ->info('Index page behavior.') |
||
| 53 | ->addDefaultsIfNotSet() |
||
| 54 | ->validate() |
||
| 55 | ->ifTrue(static function ($v) { |
||
| 56 | $amount = 0; |
||
| 57 | $amount += isset($v['template']) ? 1 : 0; |
||
| 58 | $amount += isset($v['redirect']['crud']) ? 1 : 0; |
||
| 59 | $amount += isset($v['redirect']['route']) ? 1 : 0; |
||
| 60 | |||
| 61 | return 1 < $amount; |
||
| 62 | }) |
||
| 63 | ->thenInvalid('User dashboard index page content must only be one of template, crud redirect or route redirect.') |
||
| 64 | ->end() |
||
| 65 | ->children() |
||
| 66 | ->scalarNode('template') |
||
| 67 | ->info('Render a template at the specified path.') |
||
| 68 | ->defaultValue('@ZikulaTheme/welcome.html.twig') |
||
| 69 | ->end() |
||
| 70 | ->arrayNode('redirect') |
||
| 71 | ->info('Redirect to a specific page.') |
||
| 72 | ->addDefaultsIfNotSet() |
||
| 73 | ->children() |
||
| 74 | ->scalarNode('crud') |
||
| 75 | ->info('FQCN of a CRUD controller to use as default.') |
||
| 76 | ->defaultNull() |
||
| 77 | ->end() |
||
| 78 | ->scalarNode('route') |
||
| 79 | ->info('Arbitrary route to use as default.') |
||
| 80 | ->defaultNull() |
||
| 81 | ->end() |
||
| 82 | ->arrayNode('route_parameters') |
||
| 83 | ->info('Array of route parameters (each defined by "name" and "value" entries).') |
||
| 84 | ->useAttributeAsKey('name') |
||
| 85 | ->arrayPrototype() |
||
| 86 | ->children() |
||
| 87 | ->scalarNode('name')->end() |
||
| 88 | ->scalarNode('value')->end() |
||
| 89 | ->end() |
||
| 90 | ->end() |
||
| 91 | ->end() |
||
| 92 | ->end() |
||
| 93 | ->end() |
||
| 94 | ->end() |
||
| 95 | ->end() |
||
| 96 | ->end() |
||
| 97 | ->end() |
||
| 98 | ->arrayNode('admin_dashboard') |
||
| 99 | ->info('Dashboard for admin area.') |
||
| 100 | ->addDefaultsIfNotSet() |
||
| 101 | ->children() |
||
| 102 | ->scalarNode('class') |
||
| 103 | ->info('FQCN of the dashboard controller used for the admin dashboard.') |
||
| 104 | ->defaultValue(AdminDashboardController::class) |
||
| 105 | ->end() |
||
| 106 | ->arrayNode('view') |
||
| 107 | ->info('Default view option.') |
||
| 108 | ->addDefaultsIfNotSet() |
||
| 109 | ->children() |
||
| 110 | ->booleanNode('content_maximized') |
||
| 111 | ->info('Whether the page content should span the entire browser width, instead of a defined max width.') |
||
| 112 | ->defaultTrue() |
||
| 113 | ->end() |
||
| 114 | ->booleanNode('sidebar_minimized') |
||
| 115 | ->info('Whether the sidebar (which contains the main menu) should be displayed as a narrow column instead of the expanded design.') |
||
| 116 | ->defaultFalse() |
||
| 117 | ->end() |
||
| 118 | ->end() |
||
| 119 | ->end() |
||
| 120 | ->arrayNode('content') |
||
| 121 | ->info('Index page behavior.') |
||
| 122 | ->addDefaultsIfNotSet() |
||
| 123 | ->validate() |
||
| 124 | ->ifTrue(static function ($v) { |
||
| 125 | $amount = 0; |
||
| 126 | $amount += isset($v['template']) ? 1 : 0; |
||
| 127 | $amount += isset($v['redirect']['crud']) ? 1 : 0; |
||
| 128 | $amount += isset($v['redirect']['route']) ? 1 : 0; |
||
| 129 | |||
| 130 | return 1 < $amount; |
||
| 131 | }) |
||
| 132 | ->thenInvalid('Admin dashboard index page content must only be one of template, crud redirect or route redirect.') |
||
| 133 | ->end() |
||
| 134 | ->children() |
||
| 135 | ->scalarNode('template') |
||
| 136 | ->info('Render a template at the specified path.') |
||
| 137 | ->defaultNull() |
||
| 138 | ->end() |
||
| 139 | ->arrayNode('redirect') |
||
| 140 | ->info('Redirect to a specific page.') |
||
| 141 | ->addDefaultsIfNotSet() |
||
| 142 | ->children() |
||
| 143 | ->scalarNode('crud') |
||
| 144 | ->info('FQCN of a CRUD controller to use as default.') |
||
| 145 | ->defaultNull() |
||
| 146 | ->end() |
||
| 147 | ->scalarNode('route') |
||
| 148 | ->info('Arbitrary route to use as default.') |
||
| 149 | ->defaultValue('zikulathemebundle_branding_overview') |
||
| 150 | ->end() |
||
| 151 | ->arrayNode('route_parameters') |
||
| 152 | ->info('Array of route parameters (each defined by "name" and "value" entries).') |
||
| 153 | ->useAttributeAsKey('name') |
||
| 154 | ->arrayPrototype() |
||
| 155 | ->children() |
||
| 156 | ->scalarNode('name')->end() |
||
| 157 | ->scalarNode('value')->end() |
||
| 158 | ->end() |
||
| 159 | ->end() |
||
| 160 | ->end() |
||
| 161 | ->end() |
||
| 162 | ->end() |
||
| 163 | ->end() |
||
| 164 | ->end() |
||
| 165 | ->end() |
||
| 166 | ->end() |
||
| 167 | ->booleanNode('use_compression') |
||
| 168 | ->info('Whether to enable output compression (requires PHP Zlib extension).') |
||
| 169 | ->defaultFalse() |
||
| 170 | ->end() |
||
| 171 | ->end() |
||
| 172 | ; |
||
| 173 | |||
| 174 | return $treeBuilder; |
||
| 175 | } |
||
| 177 |