Completed
Push — master ( 395774...b3be9a )
by
unknown
16s queued 12s
created

MetaSeoController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 60
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B updateSeo() 0 57 3
1
<?php
2
3
namespace Dealer\Controller;
4
5
use Dealer\Dealer;
6
use Dealer\Model\DealerMetaSeoQuery;
7
use Symfony\Component\HttpFoundation\RedirectResponse;
8
use Thelia\Controller\Admin\BaseAdminController;
9
use Thelia\Form\Exception\FormValidationException;
10
use Thelia\Tools\URL;
11
12
class MetaSeoController extends BaseAdminController
13
{
14
    public function updateSeo()
15
    {
16
        $form = $this->createForm('dealer.meta.seo');
17
        try {
18
            $this->validateForm($form);
19
20
            $databasesConfiguration = [
21
                'dealer_id' => $form->getForm()->get('dealer_id')->getData(),
22
                'slug' => $form->getForm()->get('slug')->getData(),
23
                'meta_title' => $form->getForm()->get('meta_title')->getData(),
24
                'meta_description' => $form->getForm()->get('meta_description')->getData(),
25
                'meta_keywords' => $form->getForm()->get('meta_keywords')->getData(),
26
                'meta_json' => $form->getForm()->get('meta_json')->getData(),
27
            ];
28
29
            $dealerSeo = DealerMetaSeoQuery::create()
30
                ->filterByDealerId($databasesConfiguration["dealer_id"])
31
                ->findOneOrCreate();
32
33
            $dealerSeo
34
                ->setJson( $databasesConfiguration["meta_json"])
35
                ->setSlug($databasesConfiguration["slug"])
36
                ->setMetaTitle($databasesConfiguration["meta_title"])
37
                ->setMetaDescription($databasesConfiguration["meta_description"])
38
                ->setMetaKeywords($databasesConfiguration["meta_keywords"])
39
                ->save();
40
41
            return RedirectResponse::create(
42
                URL::getInstance()->absoluteUrl('admin/module/Dealer/dealer')
43
            );
44
45
        } catch (FormValidationException $exception) {
0 ignored issues
show
Bug introduced by
The class Thelia\Form\Exception\FormValidationException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
46
            if (!$form->getForm()->isValid()) {
47
                $this->setupFormErrorContext(
48
                    'Dealer meta seo manager',
49
                    $this->createStandardFormValidationErrorMessage($exception),
50
                    $form
51
                );
52
                $form->setErrorMessage(null);
53
            } else {
54
                $this->setupFormErrorContext(
55
                    'Dealer meta seo manager',
56
                    $exception->getMessage(),
57
                    $form
58
                );
59
            }
60
61
            $response = $this->render(
62
                'module-configure',
63
                [
64
                    'module_code' => Dealer::DOMAIN_NAME
65
                ]
66
            );
67
        }
68
69
        return $response;
70
    }
71
}