Completed
Pull Request — 4.0 (#4000)
by
unknown
07:31
created

MaintenanceController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 7

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A index() 0 24 4
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