| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 74 |
| 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 |
||
| 158 | protected function addSecuritySection(ArrayNodeDefinition $node) |
||
| 159 | { |
||
| 160 | $node |
||
| 161 | ->children() |
||
| 162 | ->arrayNode('security') |
||
| 163 | ->addDefaultsIfNotSet() |
||
| 164 | ->children() |
||
| 165 | ->scalarNode('search_base') |
||
| 166 | ->info('The default DN to start the user search from.')->end() |
||
| 167 | ->scalarNode('ldap_object_type')->defaultValue('user') |
||
| 168 | ->info('The LdapTools object type for the user provider to search for.')->end() |
||
| 169 | ->scalarNode('default_role')->defaultValue('ROLE_USER') |
||
| 170 | ->info('Regardless of group membership this role will be assigned to the loaded user. Set it to null for no roles to be assigned by default.')->end() |
||
| 171 | ->booleanNode('check_groups_recursively') |
||
| 172 | ->info('If set to true then group membership will contain all groups, and nested groups, the user belongs to.')->defaultTrue()->end() |
||
| 173 | ->scalarNode('user')->defaultValue('\LdapTools\Bundle\LdapToolsBundle\Security\User\LdapUser') |
||
| 174 | ->info('The user class that the LDAP user provider will instantiate. If you change this the class must extend the default one.')->end() |
||
| 175 | ->arrayNode('default_attributes') |
||
| 176 | ->info('Set the default LDAP attributes mapped for the LDAP user provider class.') |
||
| 177 | ->addDefaultsIfNotSet() |
||
| 178 | ->children() |
||
| 179 | ->scalarNode('username')->defaultValue('username')->end() |
||
| 180 | ->scalarNode('accountNonLocked')->defaultValue('locked')->end() |
||
| 181 | ->scalarNode('accountNonExpired')->defaultValue('accountExpirationDate')->end() |
||
| 182 | ->scalarNode('enabled')->defaultValue('disabled')->end() |
||
| 183 | ->scalarNode('credentialsNonExpired')->defaultValue('passwordMustChange')->end() |
||
| 184 | ->scalarNode('groups')->defaultValue('groups')->end() |
||
| 185 | ->scalarNode('guid')->defaultValue('guid')->end() |
||
| 186 | ->scalarNode('stringRepresentation')->defaultValue('username')->end() |
||
| 187 | ->end() |
||
| 188 | ->end() |
||
| 189 | ->arrayNode('guard') |
||
| 190 | ->info('Guard specific configuration options.') |
||
| 191 | ->addDefaultsIfNotSet() |
||
| 192 | ->children() |
||
| 193 | ->scalarNode('start_path')->defaultValue('login') |
||
| 194 | ->info('The default entry point/starting path as a route name.')->end() |
||
| 195 | ->end() |
||
| 196 | ->end() |
||
| 197 | ->arrayNode('additional_attributes') |
||
| 198 | ->info('Any additional attribute values that should be available when the user is loaded.') |
||
| 199 | ->prototype('scalar')->end() |
||
| 200 | ->end() |
||
| 201 | ->arrayNode('roles') |
||
| 202 | ->info('Map LDAP group names to specific roles. If a user is a member of the group they will get the role mapped to it.') |
||
| 203 | ->useAttributeAsKey('name') |
||
| 204 | ->prototype('array') |
||
| 205 | ->beforeNormalization() |
||
| 206 | ->ifTrue(function ($v) { |
||
| 207 | return !is_array($v); |
||
| 208 | }) |
||
| 209 | ->then(function ($v) { |
||
| 210 | return [$v]; |
||
| 211 | }) |
||
| 212 | ->end() |
||
| 213 | ->prototype('scalar')->end() |
||
| 214 | ->end() |
||
| 215 | ->end() |
||
| 216 | ->scalarNode('role_ldap_type')->defaultValue('group') |
||
| 217 | ->info('The LdapTools object type for the groups used to check for roles.')->end() |
||
| 218 | ->arrayNode('role_attributes') |
||
| 219 | ->info('When searching for groups/roles for a user, map to these attributes for GUID, SID, members, or name.') |
||
| 220 | ->addDefaultsIfNotSet() |
||
| 221 | ->children() |
||
| 222 | ->scalarNode('name')->defaultValue('name')->end() |
||
| 223 | ->scalarNode('sid')->defaultValue('sid')->end() |
||
| 224 | ->scalarNode('guid')->defaultValue('guid')->end() |
||
| 225 | ->scalarNode('members')->defaultValue('members')->end() |
||
| 226 | ->end() |
||
| 227 | ->end() |
||
| 228 | ->booleanNode('refresh_user_attributes') |
||
| 229 | ->info('Set this to true if you want user attributes re-queried on a user refresh.')->defaultFalse()->end() |
||
| 230 | ->booleanNode('refresh_user_roles') |
||
| 231 | ->info('Set this to true if you want user roles re-queried on a user refresh.')->defaultFalse()->end() |
||
| 232 | ->end() |
||
| 233 | ->end() |
||
| 234 | ->end(); |
||
| 235 | } |
||
| 236 | } |
||
| 237 |