Conditions | 4 |
Paths | 8 |
Total Lines | 62 |
Code Lines | 47 |
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 |
||
110 | protected function setSecurityConfiguration(ContainerBuilder $container, array $config) |
||
111 | { |
||
112 | $roles = isset($config['roles']) ? $config['roles'] : []; |
||
113 | $additionalAttributes = isset($config['additional_attributes']) ? $config['additional_attributes'] : []; |
||
114 | |||
115 | $container->setParameter('ldap_tools.security.additional_attributes', $additionalAttributes); |
||
116 | $container->setParameter('ldap_tools.security.check_groups_recursively', $config['check_groups_recursively']); |
||
117 | $container->setParameter('ldap_tools.security.user', $config['user']); |
||
118 | $container->setParameter('ldap_tools.security.roles', $roles); |
||
119 | $container->setParameter('ldap_tools.security.default_role', $config['default_role']); |
||
120 | $container->setParameter('ldap_tools.security.guard.auth_success', [ |
||
121 | 'default_target_path' => $config['guard']['default_target_path'], |
||
122 | 'always_use_target_path' => $config['guard']['always_use_target_path'], |
||
123 | 'target_path_parameter' => $config['guard']['target_path_parameter'], |
||
124 | 'use_referrer' => $config['guard']['use_referrer'], |
||
125 | 'login_path' => $config['guard']['login_path'], |
||
126 | ]); |
||
127 | $container->setParameter('ldap_tools.security.guard.auth_failure', [ |
||
128 | 'failure_path' => $config['guard']['failure_path'], |
||
129 | 'failure_forward' => $config['guard']['failure_forward'], |
||
130 | 'failure_path_parameter' => $config['guard']['failure_path_parameter'], |
||
131 | 'login_path' => $config['guard']['login_path'], |
||
132 | ]); |
||
133 | $container->setParameter('ldap_tools.security.guard.options', [ |
||
134 | 'username_parameter' => $config['guard']['username_parameter'], |
||
135 | 'password_parameter' => $config['guard']['password_parameter'], |
||
136 | 'domain_parameter' => $config['guard']['domain_parameter'], |
||
137 | ]); |
||
138 | $container->getDefinition('ldap_tools.security.authentication.form_entry_point') |
||
139 | ->addArgument(new Reference('security.http_utils')) |
||
140 | ->addArgument($config['guard']['login_path']) |
||
141 | ->addArgument($config['guard']['use_forward']); |
||
142 | |||
143 | $container->getDefinition('ldap_tools.security.user.ldap_user_provider')->addMethodCall( |
||
144 | 'setLdapObjectType', |
||
145 | [$config['ldap_object_type']] |
||
146 | ); |
||
147 | |||
148 | $userProviderDef = $container->getDefinition('ldap_tools.security.user.ldap_user_provider'); |
||
149 | if (isset($config['search_base'])) { |
||
150 | $userProviderDef->addMethodCall( |
||
151 | 'setSearchBase', |
||
152 | [$config['search_base']] |
||
153 | ); |
||
154 | } |
||
155 | $userProviderDef->addMethodCall( |
||
156 | 'setRoleLdapType', |
||
157 | [$config['role_ldap_type']] |
||
158 | ); |
||
159 | $userProviderDef->addMethodCall( |
||
160 | 'setRoleAttributeMap', |
||
161 | [$config['role_attributes']] |
||
162 | ); |
||
163 | $userProviderDef->addMethodCall( |
||
164 | 'setRefreshAttributes', |
||
165 | [$config['refresh_user_attributes']] |
||
166 | ); |
||
167 | $userProviderDef->addMethodCall( |
||
168 | 'setRefreshRoles', |
||
169 | [$config['refresh_user_roles']] |
||
170 | ); |
||
171 | } |
||
172 | } |
||
173 |