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