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