| Conditions | 3 |
| Paths | 2 |
| Total Lines | 106 |
| Code Lines | 54 |
| 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 | protected function configureFormFields(FormMapper $formMapper): void |
||
| 24 | { |
||
| 25 | // define group zoning |
||
| 26 | $formMapper |
||
| 27 | ->tab('User') |
||
| 28 | ->with('Profile', ['class' => 'col-md-6'])->end() |
||
| 29 | ->with('General', ['class' => 'col-md-6'])->end() |
||
| 30 | //->with('Social', array('class' => 'col-md-6'))->end() |
||
| 31 | ->end() |
||
| 32 | ->tab('Security') |
||
| 33 | ->with('Status', ['class' => 'col-md-4'])->end() |
||
| 34 | ->with('Groups', ['class' => 'col-md-4'])->end() |
||
| 35 | ->with('Keys', ['class' => 'col-md-4'])->end() |
||
| 36 | ->with('Roles', ['class' => 'col-md-12'])->end() |
||
| 37 | ->end() |
||
| 38 | ->tab('ExtraFields') |
||
| 39 | ->with('ExtraFields', ['class' => 'col-md-4'])->end() |
||
| 40 | ->end(); |
||
| 41 | |||
| 42 | $now = new \DateTime(); |
||
| 43 | |||
| 44 | $formMapper |
||
| 45 | ->tab('User') |
||
| 46 | ->with('General') |
||
| 47 | ->add('username') |
||
| 48 | ->add('email') |
||
| 49 | /*->add( |
||
| 50 | 'plainPassword', |
||
| 51 | 'text', |
||
| 52 | array( |
||
| 53 | 'required' => (!$this->getSubject() || is_null( |
||
| 54 | $this->getSubject()->getId() |
||
| 55 | )), |
||
| 56 | ) |
||
| 57 | )*/ |
||
| 58 | ->end() |
||
| 59 | ->with('Profile') |
||
| 60 | /*->add( |
||
| 61 | 'dateOfBirth', |
||
| 62 | 'sonata_type_date_picker', |
||
| 63 | array( |
||
| 64 | 'years' => range(1900, $now->format('Y')), |
||
| 65 | 'dp_min_date' => '1-1-1900', |
||
| 66 | 'dp_max_date' => $now->format('c'), |
||
| 67 | 'required' => false, |
||
| 68 | ) |
||
| 69 | )*/ |
||
| 70 | ->add('firstname', null, ['required' => false]) |
||
| 71 | ->add('lastname', null, ['required' => false]) |
||
| 72 | // ->add('website', 'url', ['required' => false]) |
||
| 73 | ->add('biography', TextType::class, ['required' => false]) |
||
| 74 | /*->add( |
||
| 75 | 'gender', |
||
| 76 | 'sonata_user_gender', |
||
| 77 | array( |
||
| 78 | 'required' => true, |
||
| 79 | 'translation_domain' => $this->getTranslationDomain(), |
||
| 80 | ) |
||
| 81 | )*/ |
||
| 82 | //->add('locale', 'locale', array('required' => false)) |
||
| 83 | //->add('timezone', 'timezone', array('required' => false)) |
||
| 84 | //->add('phone', null, array('required' => false)) |
||
| 85 | ->end() |
||
| 86 | /*->with('Social') |
||
| 87 | ->add('facebookUid', null, array('required' => false)) |
||
| 88 | ->add('facebookName', null, array('required' => false)) |
||
| 89 | ->add('twitterUid', null, array('required' => false)) |
||
| 90 | ->add('twitterName', null, array('required' => false)) |
||
| 91 | ->add('gplusUid', null, array('required' => false)) |
||
| 92 | ->add('gplusName', null, array('required' => false)) |
||
| 93 | ->end()*/ |
||
| 94 | ->end(); |
||
| 95 | |||
| 96 | if ($this->getSubject() && !$this->getSubject()->hasRole('ROLE_SUPER_ADMIN')) { |
||
| 97 | $formMapper |
||
| 98 | ->tab('Security') |
||
| 99 | ->with('Status') |
||
| 100 | ->add('locked', null, ['required' => false]) |
||
| 101 | ->add('expired', null, ['required' => false]) |
||
| 102 | ->add('enabled', null, ['required' => false]) |
||
| 103 | ->add('credentialsExpired', null, ['required' => false]) |
||
| 104 | ->end() |
||
| 105 | ->with('Groups') |
||
| 106 | ->add( |
||
| 107 | 'groups', |
||
| 108 | ModelType::class, |
||
| 109 | [ |
||
| 110 | 'required' => false, |
||
| 111 | 'expanded' => true, |
||
| 112 | 'multiple' => true, |
||
| 113 | ] |
||
| 114 | ) |
||
| 115 | ->end() |
||
| 116 | ->with('Roles') |
||
| 117 | ->add( |
||
| 118 | 'realRoles', |
||
| 119 | SecurityRolesType::class, |
||
| 120 | [ |
||
| 121 | 'label' => 'form.label_roles', |
||
| 122 | 'expanded' => true, |
||
| 123 | 'multiple' => true, |
||
| 124 | 'required' => false, |
||
| 125 | ] |
||
| 126 | ) |
||
| 127 | ->end() |
||
| 128 | ->end(); |
||
| 129 | } |
||
| 193 |