| Conditions | 2 |
| Paths | 2 |
| Total Lines | 55 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 96 | protected function configureFormFields(FormMapper $formMapper) |
||
| 97 | { |
||
| 98 | $container = $this->getConfigurationPool()->getContainer(); |
||
| 99 | $securityContext = $container->get('security.context'); |
||
| 100 | |||
| 101 | if ($securityContext->isGranted('ROLE_ADMIN')) { |
||
| 102 | $roles = array( |
||
| 103 | 'ROLE_USER' => AdminEntity::getRoleString('ROLE_USER'), |
||
| 104 | 'ROLE_MODERATOR' => AdminEntity::getRoleString('ROLE_MODERATOR'), |
||
| 105 | 'ROLE_MODERATOR_LEADER' => AdminEntity::getRoleString('ROLE_MODERATOR_LEADER'), |
||
| 106 | 'ROLE_SUPER_ADMIN' => AdminEntity::getRoleString('ROLE_SUPER_ADMIN'), |
||
| 107 | ); |
||
| 108 | } else { |
||
| 109 | $roles = array( |
||
| 110 | 'ROLE_USER' => AdminEntity::getRoleString('ROLE_USER'), |
||
| 111 | 'ROLE_MODERATOR' => AdminEntity::getRoleString('ROLE_MODERATOR'), |
||
| 112 | ); |
||
| 113 | } |
||
| 114 | $formMapper |
||
| 115 | ->with('Informations personnelles', array( |
||
| 116 | 'description' => '', |
||
| 117 | 'class' => 'col-md-8', |
||
| 118 | )) |
||
| 119 | ->add('username', null, array( |
||
| 120 | 'label' => 'Nom d\'utilisateur', |
||
| 121 | )) |
||
| 122 | ->add('email', null, array( |
||
| 123 | 'label' => 'Email', |
||
| 124 | )) |
||
| 125 | ->add('firstname', null, array( |
||
| 126 | 'label' => 'Prénom', |
||
| 127 | )) |
||
| 128 | ->add('lastname', null, array( |
||
| 129 | 'label' => 'Nom', |
||
| 130 | )) |
||
| 131 | ->end() |
||
| 132 | ->with('Paramétrage', array( |
||
| 133 | 'description' => '', |
||
| 134 | 'class' => 'col-md-4', |
||
| 135 | )) |
||
| 136 | ->add('enabled', null, array( |
||
| 137 | 'label' => 'Compte actif', |
||
| 138 | )) |
||
| 139 | ->add('roles', 'choice', array( |
||
| 140 | 'multiple' => true, |
||
| 141 | 'choices' => $roles, |
||
| 142 | 'label' => 'Permissions', |
||
| 143 | )) |
||
| 144 | ->add('plainPassword', 'text', array( |
||
| 145 | 'label' => 'Changer le mot de passe', |
||
| 146 | 'required' => false, |
||
| 147 | )) |
||
| 148 | ->end() |
||
| 149 | ; |
||
| 150 | } |
||
| 151 | |||
| 170 |