Failed Conditions
Pull Request — master (#1340)
by Tsuyoshi
16:42
created

ContactController::complete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
25
namespace Eccube\Controller;
26
27
use Eccube\Application;
28
use Symfony\Component\HttpFoundation\Request;
29
30
class ContactController
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
31
{
32 5
    public function index(Application $app, Request $request)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
33
    {
34
        /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
35
        $builder = $app['form.factory']->createBuilder('contact');
36
37
        /* @var $form \Symfony\Component\Form\FormInterface */
38
        $form = $builder->getForm();
39
40
        if ($app['security']->isGranted('ROLE_USER')) {
41
            /* @var $user \Eccube\Entity\Customer */
42
            $user = $app['user'];
43
            $form->setData(array(
44
                'name01' => $user->getName01(),
45
                'name02' => $user->getName02(),
46
                'kana01' => $user->getKana01(),
47
                'kana02' => $user->getKana02(),
48
                'zip01' => $user->getZip01(),
49
                'zip02' => $user->getZip02(),
50
                'pref' => $user->getPref(),
51
                'addr01' => $user->getAddr01(),
52
                'addr02' => $user->getAddr02(),
53
                'tel01' => $user->getTel01(),
54
                'tel02' => $user->getTel02(),
55
                'tel03' => $user->getTel03(),
56
                'email' => $user->getEmail(),
57
            ));
58
        }
59
60
        $form->handleRequest($request);
61
62
        if ($form->isSubmitted() && $form->isValid()) {
63 4
            switch ($request->get('mode')) {
64 4 View Code Duplication
                case 'confirm':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
                    $builder->setAttribute('freeze', true);
66
                    $form = $builder->getForm();
67
                    $form->handleRequest($request);
68
69 1
                    return $app->render('Contact/confirm.twig', array(
70 1
                        'form' => $form->createView(),
71
                    ));
72
73 3
                case 'complete':
74
                    // メール送信
75
                    $app['eccube.service.mail']->sendrContactMail($form->getData());
76
77
                    return $app->redirect($app->url('contact_complete'));
78
            }
79
        }
80
81 1
        return $app->render('Contact/index.twig', array(
82 1
            'form' => $form->createView(),
83
        ));
84 5
    }
85
86 1
    public function complete(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
87
    {
88
        return $app->render('Contact/complete.twig');
89 1
    }
90
}
91