Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
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 |
||
97 | protected function configureFormFields(FormMapper $formMapper) |
||
98 | { |
||
99 | $formMapper |
||
100 | ->with('form.group_general') |
||
101 | ->add('name', 'Symfony\Component\Form\Extension\Core\Type\TextType') |
||
102 | ->add('title', 'Symfony\Component\Form\Extension\Core\Type\TextType') |
||
103 | ->add( |
||
104 | 'children', |
||
105 | 'Sonata\CoreBundle\Form\Type\CollectionType', |
||
106 | ['label' => false, 'type_options' => [ |
||
107 | 'delete' => true, |
||
108 | 'delete_options' => [ |
||
109 | 'type' => 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', |
||
110 | 'type_options' => ['required' => false, 'mapped' => false], |
||
111 | ], ], |
||
112 | ], |
||
113 | ['edit' => 'inline', 'inline' => 'table', 'admin_code' => 'sonata_admin_doctrine_phpcr.test.admin'] |
||
114 | ) |
||
115 | ->add( |
||
116 | 'routes', |
||
117 | 'Sonata\AdminBundle\Form\Type\ModelType', |
||
118 | ['property' => 'title', 'multiple' => true, 'expanded' => false] |
||
119 | ) |
||
120 | ->add('parentDocument', 'Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType', [ |
||
121 | 'widget' => 'browser', |
||
122 | 'root_node' => $this->getRootPath(), |
||
123 | ]) |
||
124 | ->add( |
||
125 | 'child', |
||
126 | 'Sonata\AdminBundle\Form\Type\ModelType', |
||
127 | [ |
||
128 | 'property' => 'title', |
||
129 | 'class' => 'Sonata\DoctrinePHPCRAdminBundle\Tests\Resources\Document\Content', |
||
130 | 'btn_catalogue' => 'List', |
||
131 | 'required' => false, |
||
132 | ], |
||
133 | ['admin_code' => 'sonata_admin_doctrine_phpcr.test.admin'] |
||
134 | ) |
||
135 | ->add('singleRoute', 'Symfony\Cmf\Bundle\TreeBrowserBundle\Form\Type\TreeSelectType', [ |
||
136 | 'widget' => 'browser', |
||
137 | 'root_node' => $this->getRootPath(), |
||
138 | ]) |
||
139 | ->end(); |
||
140 | |||
141 | $formMapper->getFormBuilder()->get('parentDocument')->addModelTransformer(new DocumentToPathTransformer( |
||
142 | $this->managerRegistry->getManagerForClass($this->getClass()) |
||
143 | )); |
||
144 | |||
145 | $formMapper->getFormBuilder()->get('singleRoute')->addModelTransformer(new DocumentToPathTransformer( |
||
146 | $this->managerRegistry->getManagerForClass($this->getClass()) |
||
147 | )); |
||
148 | } |
||
149 | |||
157 |