Completed
Push — 4.0 ( 16398e...769a6f )
by chihiro
25s queued 10s
created

MaintenanceController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Controller\Admin\Content;
15
16
use Eccube\Controller\AbstractController;
17
use Knp\Component\Pager\Paginator;
18
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
19
use Symfony\Component\HttpFoundation\Request;
20
use Symfony\Component\Routing\Annotation\Route;
21
use Symfony\Component\Form\Extension\Core\Type\FormType;
22
use Eccube\Service\SystemService;
23
24
class MaintenanceController extends AbstractController
25
{
26
    /**
27
     * @var SystemService
28
     */
29
    protected $systemService;
30
31
    public function __construct(SystemService $systemService) {
32
        $this->systemService = $systemService;
33
    }
34
35
    /**
36
     * メンテナンス管理ページを表示
37
     *
38
     * @Route("/%eccube_admin_route%/content/maintenance", name="admin_content_maintenance")
39
     * @Template("@admin/Content/maintenance.twig")
40
     */
41
    public function index(Request $request)
42
    {
43
        $isMaintenace = $this->systemService->isMaintenanceMode();
44
45
        $builder = $this->formFactory->createBuilder(FormType::class);
46
        $form = $builder->getForm();
47
        $form->handleRequest($request);
48
49
        if ($form->isSubmitted() && $form->isValid()) {
50
51
            $this->systemService->switchMaintenance(($request->request->get('maintenance') == "on"), null);
52
53
            $isMaintenace = $this->systemService->isMaintenanceMode();
54
55
            $this->addSuccess(($isMaintenace) ? 'admin.content.maintenance_switch__on_message' : 'admin.content.maintenance_switch__off_message', 'admin');
56
57
            return $this->redirectToRoute('admin_content_maintenance');
58
        }
59
60
        return [
61
            'form' => $form->createView(),
62
            'isMaintenance' => $isMaintenace,
63
        ];
64
    }
65
66
}
67