Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
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 |
||
114 | protected function configureFormFields(FormMapper $formMapper) |
||
115 | { |
||
116 | $formMapper |
||
117 | ->with('form.group_general') |
||
118 | ->add('name', TextType::class) |
||
119 | ->add('title', TextType::class) |
||
120 | ->add( |
||
121 | 'children', |
||
122 | CollectionType::class, |
||
123 | [ |
||
124 | 'label' => false, 'type_options' => [ |
||
125 | 'delete' => true, |
||
126 | 'delete_options' => [ |
||
127 | 'type' => CheckboxType::class, |
||
128 | 'type_options' => ['required' => false, 'mapped' => false], |
||
129 | ], |
||
130 | ], |
||
131 | ], |
||
132 | ['edit' => 'inline', 'inline' => 'table', 'admin_code' => 'sonata_admin_doctrine_phpcr.test.admin'] |
||
133 | ) |
||
134 | ->add( |
||
135 | 'routes', |
||
136 | ModelType::class, |
||
137 | ['property' => 'title', 'multiple' => true, 'expanded' => false] |
||
138 | ) |
||
139 | ->add( |
||
140 | 'parentDocument', |
||
141 | TreeSelectType::class, |
||
142 | [ |
||
143 | 'widget' => 'browser', |
||
144 | 'root_node' => $this->getRootPath(), |
||
145 | ] |
||
146 | ) |
||
147 | ->add( |
||
148 | 'child', |
||
149 | ModelType::class, |
||
150 | [ |
||
151 | 'property' => 'title', |
||
152 | 'class' => Content::class, |
||
153 | 'btn_catalogue' => 'List', |
||
154 | 'required' => false, |
||
155 | ], |
||
156 | ['admin_code' => 'sonata_admin_doctrine_phpcr.test.admin'] |
||
157 | ) |
||
158 | ->add( |
||
159 | 'singleRoute', |
||
160 | TreeSelectType::class, |
||
161 | [ |
||
162 | 'widget' => 'browser', |
||
163 | 'root_node' => $this->getRootPath(), |
||
164 | ] |
||
165 | ) |
||
166 | ->end(); |
||
167 | |||
168 | $formMapper->getFormBuilder()->get('parentDocument')->addModelTransformer( |
||
169 | new DocumentToPathTransformer( |
||
170 | $this->managerRegistry->getManagerForClass($this->getClass()) |
||
171 | ) |
||
172 | ); |
||
173 | |||
174 | $formMapper->getFormBuilder()->get('singleRoute')->addModelTransformer( |
||
175 | new DocumentToPathTransformer( |
||
176 | $this->managerRegistry->getManagerForClass($this->getClass()) |
||
177 | ) |
||
178 | ); |
||
179 | } |
||
180 | |||
188 |