| Conditions | 40 |
| Paths | 0 |
| Total Lines | 239 |
| Code Lines | 160 |
| 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 |
||
| 294 | protected function getForm() |
||
| 295 | { |
||
| 296 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 297 | |||
| 298 | $data['text_form'] = !isset($this->request->get['manufacturer_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
| 299 | $data['text_enabled'] = $this->language->get('text_enabled'); |
||
| 300 | $data['text_disabled'] = $this->language->get('text_disabled'); |
||
| 301 | $data['text_default'] = $this->language->get('text_default'); |
||
| 302 | $data['text_percent'] = $this->language->get('text_percent'); |
||
| 303 | $data['text_amount'] = $this->language->get('text_amount'); |
||
| 304 | |||
| 305 | $data['entry_name'] = $this->language->get('entry_name'); |
||
| 306 | $data['entry_description'] = $this->language->get('entry_description'); |
||
| 307 | $data['entry_description_bottom'] = $this->language->get('entry_description_bottom'); |
||
| 308 | $data['entry_meta_title'] = $this->language->get('entry_meta_title'); |
||
| 309 | $data['entry_meta_h1'] = $this->language->get('entry_meta_h1'); |
||
| 310 | $data['entry_meta_description'] = $this->language->get('entry_meta_description'); |
||
| 311 | $data['entry_keyword'] = $this->language->get('entry_keyword'); |
||
| 312 | $data['entry_image'] = $this->language->get('entry_image'); |
||
| 313 | $data['entry_sort_order'] = $this->language->get('entry_sort_order'); |
||
| 314 | $data['entry_noindex'] = $this->language->get('entry_noindex'); |
||
| 315 | $data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
||
| 316 | $data['entry_layout'] = $this->language->get('entry_layout'); |
||
| 317 | $data['entry_related_mn'] = $this->language->get('entry_related_mn'); |
||
| 318 | $data['entry_related_article'] = $this->language->get('entry_related_article'); |
||
| 319 | |||
| 320 | $data['help_keyword'] = $this->language->get('help_keyword'); |
||
| 321 | $data['help_noindex'] = $this->language->get('help_noindex'); |
||
| 322 | |||
| 323 | $data['button_save'] = $this->language->get('button_save'); |
||
| 324 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
| 325 | |||
| 326 | $data['tab_general'] = $this->language->get('tab_general'); |
||
| 327 | $data['tab_data'] = $this->language->get('tab_data'); |
||
| 328 | $data['tab_related'] = $this->language->get('tab_related'); |
||
| 329 | $data['tab_design'] = $this->language->get('tab_design'); |
||
| 330 | |||
| 331 | if (isset($this->error['warning'])) { |
||
| 332 | $data['error_warning'] = $this->error['warning']; |
||
| 333 | } else { |
||
| 334 | $data['error_warning'] = ''; |
||
| 335 | } |
||
| 336 | |||
| 337 | if (isset($this->error['name'])) { |
||
| 338 | $data['error_name'] = $this->error['name']; |
||
| 339 | } else { |
||
| 340 | $data['error_name'] = ''; |
||
| 341 | } |
||
| 342 | |||
| 343 | if (isset($this->error['meta_title'])) { |
||
| 344 | $data['error_meta_title'] = $this->error['meta_title']; |
||
| 345 | } else { |
||
| 346 | $data['error_meta_title'] = array(); |
||
| 347 | } |
||
| 348 | |||
| 349 | if (isset($this->error['meta_h1'])) { |
||
| 350 | $data['error_meta_h1'] = $this->error['meta_h1']; |
||
| 351 | } else { |
||
| 352 | $data['error_meta_h1'] = array(); |
||
| 353 | } |
||
| 354 | |||
| 355 | if (isset($this->error['keyword'])) { |
||
| 356 | $data['error_keyword'] = $this->error['keyword']; |
||
| 357 | } else { |
||
| 358 | $data['error_keyword'] = ''; |
||
| 359 | } |
||
| 360 | |||
| 361 | $url = ''; |
||
| 362 | |||
| 363 | if (isset($this->request->get['sort'])) { |
||
| 364 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 365 | } |
||
| 366 | |||
| 367 | if (isset($this->request->get['order'])) { |
||
| 368 | $url .= '&order=' . $this->request->get['order']; |
||
| 369 | } |
||
| 370 | |||
| 371 | if (isset($this->request->get['page'])) { |
||
| 372 | $url .= '&page=' . $this->request->get['page']; |
||
| 373 | } |
||
| 374 | |||
| 375 | $data['breadcrumbs'] = array(); |
||
| 376 | |||
| 377 | $data['breadcrumbs'][] = array( |
||
| 378 | 'text' => $this->language->get('text_home'), |
||
| 379 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 380 | ); |
||
| 381 | |||
| 382 | $data['breadcrumbs'][] = array( |
||
| 383 | 'text' => $this->language->get('heading_title'), |
||
| 384 | 'href' => $this->url->link('catalog/manufacturer', 'token=' . $this->session->data['token'] . $url, true) |
||
| 385 | ); |
||
| 386 | |||
| 387 | if (!isset($this->request->get['manufacturer_id'])) { |
||
| 388 | $data['action'] = $this->url->link('catalog/manufacturer/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 389 | } else { |
||
| 390 | $data['action'] = $this->url->link('catalog/manufacturer/edit', 'token=' . $this->session->data['token'] . '&manufacturer_id=' . $this->request->get['manufacturer_id'] . $url, true); |
||
| 391 | } |
||
| 392 | |||
| 393 | $data['cancel'] = $this->url->link('catalog/manufacturer', 'token=' . $this->session->data['token'] . $url, true); |
||
| 394 | |||
| 395 | if (isset($this->request->get['manufacturer_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
| 396 | $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']); |
||
| 397 | } |
||
| 398 | |||
| 399 | $data['token'] = $this->session->data['token']; |
||
| 400 | |||
| 401 | $this->load->model('localisation/language'); |
||
| 402 | $data['languages'] = $this->model_localisation_language->getLanguages(); |
||
| 403 | |||
| 404 | if (isset($this->request->post['manufacturer_description'])) { |
||
| 405 | $data['manufacturer_description'] = $this->request->post['manufacturer_description']; |
||
| 406 | } elseif (isset($this->request->get['manufacturer_id'])) { |
||
| 407 | $data['manufacturer_description'] = $this->model_catalog_manufacturer->getManufacturerDescriptions($this->request->get['manufacturer_id']); |
||
| 408 | } else { |
||
| 409 | $data['manufacturer_description'] = array(); |
||
| 410 | } |
||
| 411 | |||
| 412 | if (isset($this->request->post['name'])) { |
||
| 413 | $data['name'] = $this->request->post['name']; |
||
| 414 | } elseif (!empty($manufacturer_info)) { |
||
| 415 | $data['name'] = $manufacturer_info['name']; |
||
| 416 | } else { |
||
| 417 | $data['name'] = ''; |
||
| 418 | } |
||
| 419 | |||
| 420 | if (!empty($manufacturer_info)) { |
||
| 421 | $data['heading_title'] = $data['name'] = $manufacturer_info['name']; |
||
| 422 | } else { |
||
| 423 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 424 | } |
||
| 425 | |||
| 426 | if (isset($this->request->post['keyword'])) { |
||
| 427 | $data['keyword'] = $this->request->post['keyword']; |
||
| 428 | } elseif (!empty($manufacturer_info)) { |
||
| 429 | $data['keyword'] = $manufacturer_info['keyword']; |
||
| 430 | } else { |
||
| 431 | $data['keyword'] = ''; |
||
| 432 | } |
||
| 433 | |||
| 434 | if (isset($this->request->post['image'])) { |
||
| 435 | $data['image'] = $this->request->post['image']; |
||
| 436 | } elseif (!empty($manufacturer_info)) { |
||
| 437 | $data['image'] = $manufacturer_info['image']; |
||
| 438 | } else { |
||
| 439 | $data['image'] = ''; |
||
| 440 | } |
||
| 441 | |||
| 442 | |||
| 443 | |||
| 444 | if (isset($this->request->post['image']) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->request->post['image'])) { |
||
| 445 | $data['thumb'] = '/public_html/assets/images/' . $this->request->post['image']; |
||
| 446 | } elseif (!empty($manufacturer_info) && is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $manufacturer_info['image'])) { |
||
| 447 | $data['thumb'] = '/public_html/assets/images/' . $manufacturer_info['image']; |
||
| 448 | } else { |
||
| 449 | $data['thumb'] = '/public_html/assets/images/no_image.png'; |
||
| 450 | } |
||
| 451 | |||
| 452 | $data['placeholder'] = '/public_html/assets/images/no_image.png'; |
||
| 453 | |||
| 454 | if (isset($this->request->post['noindex'])) { |
||
| 455 | $data['noindex'] = $this->request->post['noindex']; |
||
| 456 | } elseif (!empty($manufacturer_info)) { |
||
| 457 | $data['noindex'] = $manufacturer_info['noindex']; |
||
| 458 | } else { |
||
| 459 | $data['noindex'] = 1; |
||
| 460 | } |
||
| 461 | |||
| 462 | if (isset($this->request->post['manufacturer_layout'])) { |
||
| 463 | $data['manufacturer_layout'] = $this->request->post['manufacturer_layout']; |
||
| 464 | } elseif (isset($this->request->get['manufacturer_id'])) { |
||
| 465 | $data['manufacturer_layout'] = $this->model_catalog_manufacturer->getManufacturerLayouts($this->request->get['manufacturer_id']); |
||
| 466 | } else { |
||
| 467 | $data['manufacturer_layout'] = array(); |
||
| 468 | } |
||
| 469 | |||
| 470 | $this->load->model('design/layout'); |
||
| 471 | |||
| 472 | $data['layouts'] = $this->model_design_layout->getLayouts(); |
||
| 473 | |||
| 474 | if (isset($this->request->post['sort_order'])) { |
||
| 475 | $data['sort_order'] = $this->request->post['sort_order']; |
||
| 476 | } elseif (!empty($manufacturer_info)) { |
||
| 477 | $data['sort_order'] = $manufacturer_info['sort_order']; |
||
| 478 | } else { |
||
| 479 | $data['sort_order'] = ''; |
||
| 480 | } |
||
| 481 | |||
| 482 | if (isset($this->request->post['product_related'])) { |
||
| 483 | $products = $this->request->post['product_related']; |
||
| 484 | } elseif (isset($manufacturer_info)) { |
||
| 485 | $products = $this->model_catalog_manufacturer->getProductRelated($this->request->get['manufacturer_id']); |
||
| 486 | } else { |
||
| 487 | $products = array(); |
||
| 488 | } |
||
| 489 | |||
| 490 | $data['product_related'] = array(); |
||
| 491 | |||
| 492 | $this->load->model('catalog/product'); |
||
| 493 | |||
| 494 | foreach ($products as $product_id) { |
||
| 495 | $related_info = $this->model_catalog_product->getProduct($product_id); |
||
| 496 | |||
| 497 | if ($related_info) { |
||
| 498 | $data['product_related'][] = array( |
||
| 499 | 'product_id' => $related_info['product_id'], |
||
| 500 | 'name' => $related_info['name'] |
||
| 501 | ); |
||
| 502 | } |
||
| 503 | } |
||
| 504 | |||
| 505 | if (isset($this->request->post['article_related'])) { |
||
| 506 | $articles = $this->request->post['article_related']; |
||
| 507 | } elseif (isset($manufacturer_info)) { |
||
| 508 | $articles = $this->model_catalog_manufacturer->getArticleRelated($this->request->get['manufacturer_id']); |
||
| 509 | } else { |
||
| 510 | $articles = array(); |
||
| 511 | } |
||
| 512 | |||
| 513 | $data['article_related'] = array(); |
||
| 514 | |||
| 515 | $this->load->model('blog/article'); |
||
| 516 | |||
| 517 | foreach ($articles as $article_id) { |
||
| 518 | $related_info = $this->model_blog_article->getArticle($article_id); |
||
| 519 | |||
| 520 | if ($related_info) { |
||
| 521 | $data['article_related'][] = array( |
||
| 522 | 'article_id' => $related_info['article_id'], |
||
| 523 | 'name' => $related_info['name'] |
||
| 524 | ); |
||
| 525 | } |
||
| 526 | } |
||
| 527 | |||
| 528 | $data['header'] = $this->load->controller('common/header'); |
||
| 529 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 530 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 531 | |||
| 532 | $this->response->setOutput($this->load->view('catalog/manufacturer_form', $data)); |
||
| 533 | } |
||
| 631 |
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.