| Conditions | 23 |
| Paths | > 20000 |
| Total Lines | 171 |
| Code Lines | 109 |
| 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 |
||
| 286 | protected function getForm() |
||
| 287 | { |
||
| 288 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 289 | |||
| 290 | $data['text_form'] = !isset($this->request->get['layout_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
| 291 | $data['text_route'] = $this->language->get('text_route'); |
||
| 292 | $data['text_module'] = $this->language->get('text_module'); |
||
| 293 | $data['text_default'] = $this->language->get('text_default'); |
||
| 294 | $data['text_content_top'] = $this->language->get('text_content_top'); |
||
| 295 | $data['text_content_bottom'] = $this->language->get('text_content_bottom'); |
||
| 296 | $data['text_column'] = $this->language->get('text_column'); |
||
| 297 | $data['text_edit'] = $this->language->get('text_edit'); |
||
| 298 | $data['text_remove'] = $this->language->get('text_remove'); |
||
| 299 | |||
| 300 | $data['entry_name'] = $this->language->get('entry_name'); |
||
| 301 | $data['entry_route'] = $this->language->get('entry_route'); |
||
| 302 | $data['entry_module'] = $this->language->get('entry_module'); |
||
| 303 | |||
| 304 | $data['button_save'] = $this->language->get('button_save'); |
||
| 305 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
| 306 | $data['button_route_add'] = $this->language->get('button_route_add'); |
||
| 307 | $data['button_module_add'] = $this->language->get('button_module_add'); |
||
| 308 | $data['button_edit'] = $this->language->get('button_edit'); |
||
| 309 | $data['button_remove'] = $this->language->get('button_remove'); |
||
| 310 | |||
| 311 | if (isset($this->error['warning'])) { |
||
| 312 | $data['error_warning'] = $this->error['warning']; |
||
| 313 | } else { |
||
| 314 | $data['error_warning'] = ''; |
||
| 315 | } |
||
| 316 | |||
| 317 | if (isset($this->error['name'])) { |
||
| 318 | $data['error_name'] = $this->error['name']; |
||
| 319 | } else { |
||
| 320 | $data['error_name'] = ''; |
||
| 321 | } |
||
| 322 | |||
| 323 | $url = ''; |
||
| 324 | |||
| 325 | if (isset($this->request->get['sort'])) { |
||
| 326 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 327 | } |
||
| 328 | |||
| 329 | if (isset($this->request->get['order'])) { |
||
| 330 | $url .= '&order=' . $this->request->get['order']; |
||
| 331 | } |
||
| 332 | |||
| 333 | if (isset($this->request->get['page'])) { |
||
| 334 | $url .= '&page=' . $this->request->get['page']; |
||
| 335 | } |
||
| 336 | |||
| 337 | $data['breadcrumbs'] = array(); |
||
| 338 | |||
| 339 | $data['breadcrumbs'][] = array( |
||
| 340 | 'text' => $this->language->get('text_home'), |
||
| 341 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 342 | ); |
||
| 343 | |||
| 344 | $data['breadcrumbs'][] = array( |
||
| 345 | 'text' => $this->language->get('heading_title'), |
||
| 346 | 'href' => $this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url, true) |
||
| 347 | ); |
||
| 348 | |||
| 349 | if (!isset($this->request->get['layout_id'])) { |
||
| 350 | $data['action'] = $this->url->link('design/layout/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 351 | } else { |
||
| 352 | $data['action'] = $this->url->link('design/layout/edit', 'token=' . $this->session->data['token'] . '&layout_id=' . $this->request->get['layout_id'] . $url, true); |
||
| 353 | } |
||
| 354 | |||
| 355 | $data['cancel'] = $this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url, true); |
||
| 356 | |||
| 357 | $data['token'] = $this->session->data['token']; |
||
| 358 | |||
| 359 | if (isset($this->request->get['layout_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
| 360 | $layout_info = $this->model_design_layout->getLayout($this->request->get['layout_id']); |
||
| 361 | } |
||
| 362 | |||
| 363 | if (isset($this->request->post['name'])) { |
||
| 364 | $data['name'] = $this->request->post['name']; |
||
| 365 | } elseif (!empty($layout_info)) { |
||
| 366 | $data['name'] = $layout_info['name']; |
||
| 367 | } else { |
||
| 368 | $data['name'] = ''; |
||
| 369 | } |
||
| 370 | |||
| 371 | if (isset($this->request->post['layout_route'])) { |
||
| 372 | $data['layout_routes'] = $this->request->post['layout_route']; |
||
| 373 | } elseif (isset($this->request->get['layout_id'])) { |
||
| 374 | $data['layout_routes'] = $this->model_design_layout->getLayoutRoutes($this->request->get['layout_id']); |
||
| 375 | } else { |
||
| 376 | $data['layout_routes'] = array(); |
||
| 377 | } |
||
| 378 | |||
| 379 | $data['extensions'] = array(); |
||
| 380 | |||
| 381 | // Get a list of installed modules |
||
| 382 | $this->load->model('extension/extension'); |
||
| 383 | $extensions = $this->model_extension_extension->getInstalled('module'); |
||
| 384 | |||
| 385 | // Add all the modules which have multiple settings for each module |
||
| 386 | foreach ($extensions as $code) { |
||
| 387 | $this->load->language('extension/module/' . $code); |
||
| 388 | |||
| 389 | $module_data = array(); |
||
| 390 | |||
| 391 | $this->load->model('extension/module'); |
||
| 392 | $modules = $this->model_extension_module->getModulesByCode($code); |
||
| 393 | |||
| 394 | foreach ($modules as $module) { |
||
| 395 | $module_data[] = array( |
||
| 396 | 'name' => strip_tags($module['name']), |
||
| 397 | 'code' => $code . '.' . $module['module_id'] |
||
| 398 | ); |
||
| 399 | } |
||
| 400 | |||
| 401 | \Tracy\Debugger::barDump($modules); |
||
| 402 | |||
| 403 | if ($this->config->has($code . '_status') || $module_data) { |
||
| 404 | $data['extensions'][] = array( |
||
| 405 | 'name' => strip_tags($this->language->get('heading_title')), |
||
| 406 | 'code' => $code, |
||
| 407 | 'module' => $module_data |
||
| 408 | ); |
||
| 409 | } |
||
| 410 | } |
||
| 411 | |||
| 412 | // Modules layout |
||
| 413 | if (isset($this->request->post['layout_module'])) { |
||
| 414 | $layout_modules = $this->request->post['layout_module']; |
||
| 415 | } elseif (isset($this->request->get['layout_id'])) { |
||
| 416 | $layout_modules = $this->model_design_layout->getLayoutModules($this->request->get['layout_id']); |
||
| 417 | } else { |
||
| 418 | $layout_modules = array(); |
||
| 419 | } |
||
| 420 | |||
| 421 | $data['layout_modules'] = array(); |
||
| 422 | |||
| 423 | // Add all the modules which have multiple settings for each module |
||
| 424 | foreach ($layout_modules as $layout_module) { |
||
| 425 | $part = explode('.', $layout_module['code']); |
||
| 426 | |||
| 427 | $this->load->language('extension/module/' . $part[0]); |
||
| 428 | |||
| 429 | if (!isset($part[1])) { |
||
| 430 | $data['layout_modules'][] = array( |
||
| 431 | 'name' => strip_tags($this->language->get('heading_title')), |
||
| 432 | 'code' => $layout_module['code'], |
||
| 433 | 'edit' => $this->url->link('extension/module/' . $part[0], 'token=' . $this->session->data['token'], true), |
||
| 434 | 'position' => $layout_module['position'], |
||
| 435 | 'sort_order' => $layout_module['sort_order'] |
||
| 436 | ); |
||
| 437 | } else { |
||
| 438 | $module_info = $this->model_extension_module->getModule($part[1]); |
||
| 439 | |||
| 440 | if ($module_info) { |
||
| 441 | $data['layout_modules'][] = array( |
||
| 442 | 'name' => strip_tags($module_info['name']), |
||
| 443 | 'code' => $layout_module['code'], |
||
| 444 | 'edit' => $this->url->link('extension/module/' . $part[0], 'token=' . $this->session->data['token'] . '&module_id=' . $part[1], true), |
||
| 445 | 'position' => $layout_module['position'], |
||
| 446 | 'sort_order' => $layout_module['sort_order'] |
||
| 447 | ); |
||
| 448 | } |
||
| 449 | } |
||
| 450 | } |
||
| 451 | |||
| 452 | $data['header'] = $this->load->controller('common/header'); |
||
| 453 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 454 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 455 | |||
| 456 | $this->response->setOutput($this->load->view('design/layout_form', $data)); |
||
| 457 | } |
||
| 530 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.