Conditions | 1 |
Paths | 1 |
Total Lines | 63 |
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 |
||
83 | protected function _prepareForm(): self |
||
84 | { |
||
85 | /** @var \Magento\Framework\Data\Form $form */ |
||
86 | $form = $this->_formFactory->create( |
||
87 | [ |
||
88 | 'data' => [ |
||
89 | 'id' => 'edit_form', |
||
90 | 'action' => $this->getFormTargetUrl(), |
||
91 | 'method' => 'post' |
||
92 | ] |
||
93 | ] |
||
94 | ); |
||
95 | |||
96 | $form->setHtmlIdPrefix('purgesingle_'); |
||
97 | |||
98 | $fieldset = $form->addFieldset( |
||
99 | 'base_fieldset', |
||
100 | [ |
||
101 | 'class' => 'fieldset-wide' |
||
102 | ] |
||
103 | ); |
||
104 | |||
105 | $fieldset->addField( |
||
106 | self::URL_FORM_PARAM, |
||
107 | 'text', |
||
108 | [ |
||
109 | 'name' => self::URL_FORM_PARAM, |
||
110 | 'label' => __('URL to purge'), |
||
111 | 'title' => __('URL to purge'), |
||
112 | 'required' => false, |
||
113 | 'note' => __('Relative URL, e.g. * or bizuteria. If empty, homepage will be purged') |
||
114 | |||
115 | ] |
||
116 | ); |
||
117 | |||
118 | $fieldset->addField( |
||
119 | self::STORE_VIEW_FORM_PARAM, |
||
120 | 'select', |
||
121 | [ |
||
122 | 'name' => self::STORE_VIEW_FORM_PARAM, |
||
123 | 'label' => __('Store View'), |
||
124 | 'title' => __('Store View'), |
||
125 | 'required' => true, |
||
126 | 'values' => $this->systemStore->getStoreValuesForForm(false, true) |
||
127 | ] |
||
128 | ); |
||
129 | |||
130 | $fieldset->addField( |
||
131 | self::FORCE_PURGE_FORM_PARAM, |
||
132 | 'checkbox', |
||
133 | [ |
||
134 | 'name' => self::FORCE_PURGE_FORM_PARAM, |
||
135 | 'label' => __('Force purge'), |
||
136 | 'title' => __('Force purge'), |
||
137 | 'required' => false, |
||
138 | ] |
||
139 | ); |
||
140 | |||
141 | $form->setUseContainer(true); |
||
142 | $this->setForm($form); |
||
143 | |||
144 | return parent::_prepareForm(); |
||
145 | } |
||
146 | |||
155 |