Conditions | 9 |
Paths | 80 |
Total Lines | 335 |
Code Lines | 239 |
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 |
||
60 | private function installExampleData(): void |
||
61 | { |
||
62 | // insert/get extra ids |
||
63 | $extras = []; |
||
64 | $extras['blog_block'] = $this->insertExtra('Blog', ModuleExtraType::block(), 'Blog'); |
||
65 | $extras['blog_widget_recent_comments'] = $this->insertExtra( |
||
66 | 'Blog', |
||
67 | ModuleExtraType::widget(), |
||
68 | 'RecentComments', |
||
69 | 'RecentComments' |
||
70 | ); |
||
71 | $extras['blog_widget_categories'] = $this->insertExtra( |
||
72 | 'Blog', |
||
73 | ModuleExtraType::widget(), |
||
74 | 'Categories', |
||
75 | 'Categories' |
||
76 | ); |
||
77 | $extras['blog_widget_archive'] = $this->insertExtra('Blog', ModuleExtraType::widget(), 'Archive', 'Archive'); |
||
78 | $extras['blog_widget_recent_articles_full'] = $this->insertExtra( |
||
79 | 'Blog', |
||
80 | ModuleExtraType::widget(), |
||
81 | 'RecentArticlesFull', |
||
82 | 'RecentArticlesFull' |
||
83 | ); |
||
84 | $extras['blog_widget_related_articles'] = $this->insertExtra( |
||
85 | 'Blog', |
||
86 | ModuleExtraType::widget(), |
||
87 | 'RelatedArticles', |
||
88 | 'RelatedArticles' |
||
89 | ); |
||
90 | $extras['blog_widget_recent_articles_list'] = $this->insertExtra( |
||
91 | 'Blog', |
||
92 | ModuleExtraType::widget(), |
||
93 | 'RecentArticlesList', |
||
94 | 'RecentArticlesList' |
||
95 | ); |
||
96 | if (in_array('Faq', $this->getVariable('selected_modules'))) { |
||
|
|||
97 | $extras['faq_block'] = $this->insertExtra('Faq', ModuleExtraType::block(), 'Faq'); |
||
98 | } |
||
99 | if (in_array('Mailmotor', $this->getVariable('selected_modules'))) { |
||
100 | $extras['mailmotor_subscribe'] = $this->insertExtra( |
||
101 | 'Mailmotor', |
||
102 | ModuleExtraType::block(), |
||
103 | 'SubscribeForm', |
||
104 | 'Subscribe' |
||
105 | ); |
||
106 | $extras['mailmotor_unsubscribe'] = $this->insertExtra( |
||
107 | 'Mailmotor', |
||
108 | ModuleExtraType::block(), |
||
109 | 'UnsubscribeForm', |
||
110 | 'Unsubscribe' |
||
111 | ); |
||
112 | } |
||
113 | $extras['tags_block'] = $this->insertExtra('Tags', ModuleExtraType::block(), 'Tags'); |
||
114 | if (in_array('Profiles', $this->getVariable('selected_modules'))) { |
||
115 | $extras['profiles_forgot_password'] = $this->insertExtra( |
||
116 | 'Profiles', |
||
117 | ModuleExtraType::block(), |
||
118 | 'ForgotPassword', |
||
119 | 'ForgotPassword' |
||
120 | ); |
||
121 | $extras['profiles_block'] = $this->insertExtra( |
||
122 | 'Profiles', |
||
123 | ModuleExtraType::block(), |
||
124 | 'Dashboard' |
||
125 | ); |
||
126 | $extras['profiles_login'] = $this->insertExtra( |
||
127 | 'Profiles', |
||
128 | ModuleExtraType::block(), |
||
129 | 'Login', |
||
130 | 'Login' |
||
131 | ); |
||
132 | $extras['profiles_logout'] = $this->insertExtra( |
||
133 | 'Profiles', |
||
134 | ModuleExtraType::block(), |
||
135 | 'Logout', |
||
136 | 'Logout' |
||
137 | ); |
||
138 | $extras['profiles_change_email'] = $this->insertExtra( |
||
139 | 'Profiles', |
||
140 | ModuleExtraType::block(), |
||
141 | 'ChangeEmail', |
||
142 | 'ChangeEmail' |
||
143 | ); |
||
144 | $extras['profiles_change_password'] = $this->insertExtra( |
||
145 | 'Profiles', |
||
146 | ModuleExtraType::block(), |
||
147 | 'ChangePassword', |
||
148 | 'ChangePassword' |
||
149 | ); |
||
150 | $extras['profiles_settings'] = $this->insertExtra( |
||
151 | 'Profiles', |
||
152 | ModuleExtraType::block(), |
||
153 | 'Settings', |
||
154 | 'Settings' |
||
155 | ); |
||
156 | $extras['profiles_register'] = $this->insertExtra( |
||
157 | 'Profiles', |
||
158 | ModuleExtraType::block(), |
||
159 | 'Register', |
||
160 | 'Register' |
||
161 | ); |
||
162 | $extras['profiles_resend_activation'] = $this->insertExtra( |
||
163 | 'Profiles', |
||
164 | ModuleExtraType::block(), |
||
165 | 'ResendActivation', |
||
166 | 'ResendActivation' |
||
167 | ); |
||
168 | $extras['profiles_login_box'] = $this->insertExtra( |
||
169 | 'Profiles', |
||
170 | ModuleExtraType::widget(), |
||
171 | 'LoginBox', |
||
172 | 'LoginBox' |
||
173 | ); |
||
174 | $extras['profiles_login_link'] = $this->insertExtra( |
||
175 | 'Profiles', |
||
176 | ModuleExtraType::widget(), |
||
177 | 'LoginLink', |
||
178 | 'LoginLink' |
||
179 | ); |
||
180 | $extras['profiles_secure_page'] = $this->insertExtra( |
||
181 | 'Profiles', |
||
182 | ModuleExtraType::widget(), |
||
183 | 'SecurePage', |
||
184 | 'SecurePage' |
||
185 | ); |
||
186 | } |
||
187 | |||
188 | // loop languages |
||
189 | foreach ($this->getLanguages() as $language) { |
||
190 | // insert modules page |
||
191 | $modulesPageId = $this->insertPage( |
||
192 | [ |
||
193 | 'id' => 4, |
||
194 | 'title' => SpoonFilter::ucfirst( |
||
195 | $this->getLocale('Modules', 'Core', $language, 'lbl', 'Frontend') |
||
196 | ), |
||
197 | 'type' => 'page', |
||
198 | 'language' => $language, |
||
199 | 'parent_id' => BackendModel::HOME_PAGE_ID, |
||
200 | ], |
||
201 | null, |
||
202 | ['extra_id' => $this->getExtraId('subpages')], |
||
203 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
204 | ); |
||
205 | |||
206 | // check if pages already exist for this language |
||
207 | if (!$this->hasPage($language)) { |
||
208 | // re-insert homepage |
||
209 | $this->insertPage( |
||
210 | [ |
||
211 | 'id' => BackendModel::HOME_PAGE_ID, |
||
212 | 'parent_id' => BackendPagesModel::NO_PARENT_PAGE_ID, |
||
213 | 'template_id' => $this->getTemplateId('home'), |
||
214 | 'title' => SpoonFilter::ucfirst($this->getLocale('Home', 'Core', $language)), |
||
215 | 'language' => $language, |
||
216 | 'allow_move' => false, |
||
217 | 'allow_delete' => false, |
||
218 | ], |
||
219 | null, |
||
220 | ['html' => __DIR__ . '/Data/' . $language . '/sample1.txt'], |
||
221 | ['extra_id' => $extras['blog_widget_recent_articles_list'], 'position' => 'main'], |
||
222 | ['extra_id' => $extras['blog_widget_recent_comments'], 'position' => 'main'], |
||
223 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
224 | ); |
||
225 | |||
226 | // blog |
||
227 | $this->insertPage( |
||
228 | [ |
||
229 | 'title' => SpoonFilter::ucfirst( |
||
230 | $this->getLocale('Blog', 'Core', $language, 'lbl', 'Frontend') |
||
231 | ), |
||
232 | 'language' => $language, |
||
233 | 'parent_id' => $modulesPageId, |
||
234 | ], |
||
235 | null, |
||
236 | ['extra_id' => $extras['blog_block']], |
||
237 | ['extra_id' => $extras['blog_widget_recent_comments'], 'position' => 'main'], |
||
238 | ['extra_id' => $extras['blog_widget_categories'], 'position' => 'main'], |
||
239 | ['extra_id' => $extras['blog_widget_archive'], 'position' => 'main'], |
||
240 | ['extra_id' => $extras['blog_widget_recent_articles_list'], 'position' => 'main'], |
||
241 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
242 | ); |
||
243 | |||
244 | // faq |
||
245 | if (in_array('Faq', $this->getVariable('selected_modules'))) { |
||
246 | $this->insertPage( |
||
247 | [ |
||
248 | 'title' => 'FAQ', |
||
249 | 'language' => $language, |
||
250 | 'parent_id' => $modulesPageId, |
||
251 | ], |
||
252 | null, |
||
253 | ['extra_id' => $extras['faq_block']] |
||
254 | ); |
||
255 | } |
||
256 | |||
257 | // mailmotor |
||
258 | if (in_array('Mailmotor', $this->getVariable('selected_modules'))) { |
||
259 | $newslettersPageId = $this->insertPage( |
||
260 | [ |
||
261 | 'title' => 'Newsletters', |
||
262 | 'language' => $language, |
||
263 | 'parent_id' => $modulesPageId, |
||
264 | ] |
||
265 | ); |
||
266 | $this->insertPage( |
||
267 | ['parent_id' => $newslettersPageId, 'title' => 'Subscribe', 'language' => $language], |
||
268 | null, |
||
269 | ['extra_id' => $extras['mailmotor_subscribe'], 'position' => 'main'] |
||
270 | ); |
||
271 | $this->insertPage( |
||
272 | ['parent_id' => $newslettersPageId, 'title' => 'Unsubscribe', 'language' => $language], |
||
273 | null, |
||
274 | ['extra_id' => $extras['mailmotor_unsubscribe'], 'position' => 'main'] |
||
275 | ); |
||
276 | } |
||
277 | |||
278 | // tags |
||
279 | $this->insertPage( |
||
280 | [ |
||
281 | 'title' => 'Tags', |
||
282 | 'language' => $language, |
||
283 | 'parent_id' => $modulesPageId, |
||
284 | ], |
||
285 | null, |
||
286 | ['extra_id' => $extras['tags_block'], 'position' => 'main'], |
||
287 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
288 | ); |
||
289 | |||
290 | // profiles |
||
291 | if (in_array('Profiles', $this->getVariable('selected_modules'))) { |
||
292 | $profilesPageId = $this->insertPage( |
||
293 | [ |
||
294 | 'title' => 'Profiles', |
||
295 | 'language' => $language, |
||
296 | 'parent_id' => $modulesPageId, |
||
297 | ], |
||
298 | null, |
||
299 | ['extra_id' => $this->getExtraId('subpages')], |
||
300 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
301 | ); |
||
302 | $this->insertPage( |
||
303 | [ |
||
304 | 'title' => SpoonFilter::ucfirst($this->getLocale('ForgotPassword', 'Core', $language, 'lbl', 'Backend')), |
||
305 | 'language' => $language, |
||
306 | 'parent_id' => $profilesPageId, |
||
307 | ], |
||
308 | null, |
||
309 | ['extra_id' => $extras['profiles_forgot_password'], 'position' => 'main'], |
||
310 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
311 | ); |
||
312 | $this->insertPage( |
||
313 | [ |
||
314 | 'title' => SpoonFilter::ucfirst( |
||
315 | $this->getLocale('ResendActivation', 'Core', $language, 'lbl', 'Backend') |
||
316 | ), |
||
317 | 'language' => $language, |
||
318 | 'parent_id' => $profilesPageId, |
||
319 | ], |
||
320 | null, |
||
321 | ['extra_id' => $extras['profiles_resend_activation'], 'position' => 'main'], |
||
322 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
323 | ); |
||
324 | $this->insertPage( |
||
325 | [ |
||
326 | 'title' => SpoonFilter::ucfirst($this->getLocale('Login', 'Core', $language, 'lbl', 'Backend')), |
||
327 | 'language' => $language, |
||
328 | 'parent_id' => $profilesPageId, |
||
329 | ], |
||
330 | null, |
||
331 | ['extra_id' => $extras['profiles_login'], 'position' => 'main'], |
||
332 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
333 | ); |
||
334 | $this->insertPage( |
||
335 | [ |
||
336 | 'title' => SpoonFilter::ucfirst($this->getLocale('Register', 'Core', $language, 'lbl', 'Backend')), |
||
337 | 'language' => $language, |
||
338 | 'parent_id' => $profilesPageId, |
||
339 | ], |
||
340 | null, |
||
341 | ['extra_id' => $extras['profiles_register'], 'position' => 'main'], |
||
342 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
343 | ); |
||
344 | $this->insertPage( |
||
345 | [ |
||
346 | 'title' => SpoonFilter::ucfirst($this->getLocale('Logout', 'Core', $language, 'lbl', 'Backend')), |
||
347 | 'language' => $language, |
||
348 | 'parent_id' => $profilesPageId, |
||
349 | ], |
||
350 | null, |
||
351 | ['extra_id' => $extras['profiles_logout'], 'position' => 'main'], |
||
352 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
353 | ); |
||
354 | $this->insertPage( |
||
355 | [ |
||
356 | 'title' => SpoonFilter::ucfirst($this->getLocale('Profile', 'Core', $language, 'lbl', 'Backend')), |
||
357 | 'language' => $language, |
||
358 | 'parent_id' => $profilesPageId, |
||
359 | ], |
||
360 | null, |
||
361 | ['extra_id' => $extras['profiles_block'], 'position' => 'main'], |
||
362 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
363 | ); |
||
364 | $this->insertPage( |
||
365 | [ |
||
366 | 'title' => SpoonFilter::ucfirst( |
||
367 | $this->getLocale('ProfileSettings', 'Core', $language, 'lbl', 'Backend') |
||
368 | ), |
||
369 | 'language' => $language, |
||
370 | 'parent_id' => $profilesPageId, |
||
371 | ], |
||
372 | null, |
||
373 | ['extra_id' => $extras['profiles_settings'], 'position' => 'main'], |
||
374 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
375 | ); |
||
376 | $this->insertPage( |
||
377 | [ |
||
378 | 'title' => SpoonFilter::ucfirst($this->getLocale('ChangeEmail', 'Core', $language, 'lbl', 'Backend')), |
||
379 | 'language' => $language, |
||
380 | 'parent_id' => $profilesPageId, |
||
381 | ], |
||
382 | null, |
||
383 | ['extra_id' => $extras['profiles_change_email'], 'position' => 'main'], |
||
384 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
385 | ); |
||
386 | $this->insertPage( |
||
387 | [ |
||
388 | 'title' => SpoonFilter::ucfirst($this->getLocale('ChangePassword', 'Core', $language, 'lbl', 'Backend')), |
||
389 | 'language' => $language, |
||
390 | 'parent_id' => $profilesPageId, |
||
391 | ], |
||
392 | null, |
||
393 | ['extra_id' => $extras['profiles_change_password'], 'position' => 'main'], |
||
394 | ['extra_id' => $this->getExtraId('search_form'), 'position' => 'top'] |
||
395 | ); |
||
517 |