| Conditions | 1 |
| Paths | 1 |
| Total 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 |
||
| 102 | protected function configureFormFields(FormMapper $formMapper): void |
||
| 103 | { |
||
| 104 | $formMapper |
||
| 105 | ->with('form.group_general') |
||
| 106 | ->add('name', TextType::class) |
||
| 107 | ->add('title', TextType::class) |
||
| 108 | ->add( |
||
| 109 | 'children', |
||
| 110 | CollectionType::class, |
||
| 111 | ['label' => false, 'type_options' => [ |
||
| 112 | 'delete' => true, |
||
| 113 | 'delete_options' => [ |
||
| 114 | 'type' => CheckboxType::class, |
||
| 115 | 'type_options' => ['required' => false, 'mapped' => false], |
||
| 116 | ], ], |
||
| 117 | ], |
||
| 118 | ['edit' => 'inline', 'inline' => 'table', 'admin_code' => 'sonata_admin_doctrine_phpcr.test.admin'] |
||
| 119 | ) |
||
| 120 | ->add( |
||
| 121 | 'routes', |
||
| 122 | ModelType::class, |
||
| 123 | ['property' => 'title', 'multiple' => true, 'expanded' => false] |
||
| 124 | ) |
||
| 125 | ->add('parentDocument', |
||
| 126 | TreeSelectType::class, [ |
||
| 127 | 'widget' => 'browser', |
||
| 128 | 'root_node' => $this->getRootPath(), |
||
| 129 | ]) |
||
| 130 | ->add( |
||
| 131 | 'child', |
||
| 132 | ModelType::class, |
||
| 133 | [ |
||
| 134 | 'property' => 'title', |
||
| 135 | 'class' => Content::class, |
||
| 136 | 'btn_catalogue' => 'List', |
||
| 137 | 'required' => false, |
||
| 138 | ], |
||
| 139 | ['admin_code' => 'sonata_admin_doctrine_phpcr.test.admin'] |
||
| 140 | ) |
||
| 141 | ->add('singleRoute', |
||
| 142 | TreeSelectType::class, [ |
||
| 143 | 'widget' => 'browser', |
||
| 144 | 'root_node' => $this->getRootPath(), |
||
| 145 | ]) |
||
| 146 | ->end(); |
||
| 147 | |||
| 148 | $formMapper->getFormBuilder()->get('parentDocument')->addModelTransformer(new DocumentToPathTransformer( |
||
| 149 | $this->managerRegistry->getManagerForClass($this->getClass()) |
||
| 150 | )); |
||
| 151 | |||
| 152 | $formMapper->getFormBuilder()->get('singleRoute')->addModelTransformer(new DocumentToPathTransformer( |
||
| 153 | $this->managerRegistry->getManagerForClass($this->getClass()) |
||
| 154 | )); |
||
| 155 | } |
||
| 156 | |||
| 164 |