Conditions | 1 |
Paths | 1 |
Total Lines | 75 |
Code Lines | 51 |
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 |
||
48 | private function addMainFieldset(FormInterface $form) |
||
49 | { |
||
50 | $mainData = $form->addChild($this->getElement('nested_fieldset', [ |
||
51 | 'name' => 'main_data', |
||
52 | 'label' => 'common.fieldset.general', |
||
53 | ])); |
||
54 | |||
55 | $languageData = $mainData->addChild($this->getElement('language_fieldset', [ |
||
56 | 'name' => 'translations', |
||
57 | 'label' => 'common.fieldset.translations', |
||
58 | 'transformer' => $this->getRepositoryTransformer('translation', $this->get('page.repository')), |
||
59 | ])); |
||
60 | |||
61 | $name = $languageData->addChild($this->getElement('text_field', [ |
||
62 | 'name' => 'name', |
||
63 | 'label' => 'common.label.name', |
||
64 | 'rules' => [ |
||
65 | $this->getRule('required'), |
||
66 | ], |
||
67 | ])); |
||
68 | |||
69 | $languageData->addChild($this->getElement('slug_field', [ |
||
70 | 'name' => 'slug', |
||
71 | 'label' => 'common.label.slug', |
||
72 | 'name_field' => $name, |
||
73 | 'generate_route' => 'route.generate', |
||
74 | 'translatable_id' => $this->getRequestHelper()->getAttributesBagParam('id'), |
||
75 | 'rules' => [ |
||
76 | $this->getRule('required'), |
||
77 | ], |
||
78 | ])); |
||
79 | |||
80 | $mainData->addChild($this->getElement('checkbox', [ |
||
81 | 'name' => 'publish', |
||
82 | 'label' => 'common.label.publish', |
||
83 | 'comment' => 'page.comment.publish', |
||
84 | 'default' => 1, |
||
85 | ])); |
||
86 | |||
87 | $mainData->addChild($this->getElement('text_field', [ |
||
88 | 'name' => 'hierarchy', |
||
89 | 'label' => 'common.label.hierarchy', |
||
90 | 'rules' => [ |
||
91 | $this->getRule('required'), |
||
92 | ], |
||
93 | ])); |
||
94 | |||
95 | $mainData->addChild($this->getElement('text_field', [ |
||
96 | 'name' => 'section', |
||
97 | 'label' => 'page.label.section', |
||
98 | ])); |
||
99 | |||
100 | $mainData->addChild($this->getElement('tree', [ |
||
101 | 'name' => 'parent', |
||
102 | 'label' => 'page.label.parent', |
||
103 | 'choosable' => true, |
||
104 | 'selectable' => false, |
||
105 | 'sortable' => false, |
||
106 | 'clickable' => false, |
||
107 | 'items' => $this->get('page.dataset.admin')->getResult('flat_tree'), |
||
108 | 'restrict' => $this->getRequestHelper()->getAttributesBagParam('id'), |
||
109 | 'transformer' => $this->getRepositoryTransformer('entity', $this->get('page.repository')), |
||
110 | ])); |
||
111 | |||
112 | $mainData->addChild($this->getElement('tip', [ |
||
113 | 'tip' => $this->trans('page.tip.client_groups'), |
||
114 | ])); |
||
115 | |||
116 | $mainData->addChild($this->getElement('multi_select', [ |
||
117 | 'name' => 'clientGroups', |
||
118 | 'label' => 'page.label.client_groups', |
||
119 | 'options' => $this->get('client_group.dataset.admin')->getResult('select'), |
||
120 | 'transformer' => $this->getRepositoryTransformer('collection', $this->get('client_group.repository')), |
||
121 | ])); |
||
122 | } |
||
123 | |||
202 |