1 | <?php |
||
32 | 5 | class ContactController |
|
|
|||
33 | { |
||
34 | /** |
||
35 | * お問い合わせ画面. |
||
36 | * |
||
37 | * @param Application $app |
||
38 | * @param Request $request |
||
39 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
||
40 | */ |
||
41 | public function index(Application $app, Request $request) |
||
42 | { |
||
43 | $builder = $app['form.factory']->createBuilder('contact'); |
||
44 | |||
45 | if ($app->isGranted('ROLE_USER')) { |
||
46 | $user = $app['user']; |
||
47 | $builder->setData( |
||
48 | array( |
||
49 | 'name01' => $user->getName01(), |
||
50 | 'name02' => $user->getName02(), |
||
51 | 'kana01' => $user->getKana01(), |
||
52 | 'kana02' => $user->getKana02(), |
||
53 | 'zip01' => $user->getZip01(), |
||
54 | 'zip02' => $user->getZip02(), |
||
55 | 'pref' => $user->getPref(), |
||
56 | 'addr01' => $user->getAddr01(), |
||
57 | 'addr02' => $user->getAddr02(), |
||
58 | 'tel01' => $user->getTel01(), |
||
59 | 'tel02' => $user->getTel02(), |
||
60 | 'tel03' => $user->getTel03(), |
||
61 | 'email' => $user->getEmail(), |
||
62 | ) |
||
63 | 4 | ); |
|
64 | 4 | } |
|
65 | |||
66 | // FRONT_CONTACT_INDEX_INITIALIZE |
||
67 | $event = new EventArgs( |
||
68 | array( |
||
69 | 1 | 'builder' => $builder, |
|
70 | 1 | ), |
|
71 | $request |
||
72 | ); |
||
73 | 3 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_INITIALIZE, $event); |
|
74 | |||
75 | $form = $builder->getForm(); |
||
76 | $form->handleRequest($request); |
||
77 | |||
78 | if ($form->isSubmitted() && $form->isValid()) { |
||
79 | switch ($request->get('mode')) { |
||
80 | case 'confirm': |
||
81 | 1 | $builder->setAttribute('freeze', true); |
|
82 | 1 | $form = $builder->getForm(); |
|
83 | $form->handleRequest($request); |
||
84 | 5 | ||
85 | return $app->render('Contact/confirm.twig', array( |
||
86 | 1 | 'form' => $form->createView(), |
|
87 | )); |
||
88 | |||
89 | 1 | case 'complete': |
|
90 | |||
91 | $data = $form->getData(); |
||
92 | |||
93 | $event = new EventArgs( |
||
94 | array( |
||
95 | 'form' => $form, |
||
96 | 'data' => $data, |
||
97 | ), |
||
98 | $request |
||
99 | ); |
||
100 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_COMPLETE, $event); |
||
101 | |||
102 | $data = $event->getArgument('data'); |
||
103 | |||
104 | // メール送信 |
||
105 | $app['eccube.service.mail']->sendContactMail($data); |
||
106 | |||
107 | return $app->redirect($app->url('contact_complete')); |
||
108 | } |
||
109 | } |
||
110 | |||
111 | return $app->render('Contact/index.twig', array( |
||
112 | 'form' => $form->createView(), |
||
113 | )); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * お問い合わせ完了画面. |
||
118 | * |
||
119 | * @param Application $app |
||
120 | * @return \Symfony\Component\HttpFoundation\Response |
||
121 | */ |
||
122 | public function complete(Application $app) |
||
126 | } |
||
127 |