Conditions | 10 |
Paths | 20 |
Total Lines | 112 |
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 |
||
65 | protected function configureFormFields(FormMapper $form): void |
||
66 | { |
||
67 | $groupOptions = array(); |
||
68 | if (($this->hasRequest()) && ($this->isCurrentRoute('create'))) { |
||
69 | $idGroup = $this->getRequest()->get('idGroup', null); |
||
70 | |||
71 | if ($idGroup !== null) { |
||
72 | $this->getRequest()->getSession()->set('vgrcorebundle_admin_chart.idGroup', $idGroup); |
||
73 | } |
||
74 | |||
75 | if ($this->getRequest()->getSession()->has('vgrcorebundle_admin_chart.idGroup')) { |
||
76 | $idGroup = $this->getRequest()->getSession()->get('vgrcorebundle_admin_chart.idGroup'); |
||
77 | $entityManager = $this->getModelManager() |
||
78 | ->getEntityManager('VideoGamesRecords\CoreBundle\Entity\Group'); |
||
|
|||
79 | $group = $entityManager->getReference('VideoGamesRecords\CoreBundle\Entity\Group', $idGroup); |
||
80 | $groupOptions = array('data' => $group); |
||
81 | } |
||
82 | } |
||
83 | |||
84 | $form |
||
85 | ->add('id', TextType::class, array( |
||
86 | 'label' => 'label.id', |
||
87 | 'attr' => array( |
||
88 | 'readonly' => true, |
||
89 | ) |
||
90 | )); |
||
91 | |||
92 | if ($this->isCurrentRoute('create') || $this->isCurrentRoute('edit')) { |
||
93 | $btnCalalogue = $this->isCurrentRoute('create'); |
||
94 | $form-> |
||
95 | add( |
||
96 | 'group', |
||
97 | ModelListType::class, |
||
98 | array_merge( |
||
99 | $groupOptions, |
||
100 | [ |
||
101 | 'data_class' => null, |
||
102 | 'btn_add' => false, |
||
103 | 'btn_list' => $btnCalalogue, |
||
104 | 'btn_edit' => false, |
||
105 | 'btn_delete' => false, |
||
106 | 'btn_catalogue' => $btnCalalogue, |
||
107 | 'label' => 'label.group', |
||
108 | ] |
||
109 | ) |
||
110 | ); |
||
111 | } |
||
112 | |||
113 | $form |
||
114 | ->add('libChartEn', TextType::class, [ |
||
115 | 'label' => 'label.name.en', |
||
116 | 'required' => true, |
||
117 | ]) |
||
118 | ->add('libChartFr', TextType::class, [ |
||
119 | 'label' => 'label.name.fr', |
||
120 | 'required' => false, |
||
121 | ]); |
||
122 | |||
123 | $form->add('isDlc', CheckboxType::class, [ |
||
124 | 'label' => 'label.isDlc', |
||
125 | 'required' => false, |
||
126 | ]); |
||
127 | |||
128 | $form->add('isProofVideoOnly', CheckboxType::class, [ |
||
129 | 'label' => 'label.isProofVideoOnly', |
||
130 | 'required' => false, |
||
131 | ]); |
||
132 | |||
133 | |||
134 | if ($this->isCurrentRoute('create') || $this->isCurrentRoute('edit')) { |
||
135 | $form |
||
136 | ->add( |
||
137 | 'statusPlayer', |
||
138 | ChoiceType::class, |
||
139 | array( |
||
140 | 'label' => 'label.chart.statusPlayer', |
||
141 | 'choices' => ChartStatus::getStatusChoices() |
||
142 | ) |
||
143 | ) |
||
144 | ->add( |
||
145 | 'statusTeam', |
||
146 | ChoiceType::class, |
||
147 | array( |
||
148 | 'label' => 'label.chart.statusTeam', |
||
149 | 'choices' => ChartStatus::getStatusChoices() |
||
150 | ) |
||
151 | ); |
||
152 | } |
||
153 | |||
154 | |||
155 | $form |
||
156 | ->add('libs', CollectionType::class, array( |
||
157 | 'label' => 'label.libs', |
||
158 | 'by_reference' => false, |
||
159 | 'help' => (($this->isCurrentRoute('create')) ? |
||
160 | 'label.libs.help' : ''), |
||
161 | 'type_options' => array( |
||
162 | // Prevents the "Delete" option from being displayed |
||
163 | 'delete' => false, |
||
164 | 'delete_options' => array( |
||
165 | // You may otherwise choose to put the field but hide it |
||
166 | 'type' => CheckboxType::class, |
||
167 | // In that case, you need to fill in the options as well |
||
168 | 'type_options' => array( |
||
169 | 'mapped' => false, |
||
170 | 'required' => false, |
||
171 | ) |
||
172 | ) |
||
173 | ) |
||
174 | ), array( |
||
175 | 'edit' => 'inline', |
||
176 | 'inline' => 'table', |
||
177 | )); |
||
312 |