Passed
Push — master ( 8a455a...42a228 )
by Craig
07:01
created

AjaxUpgradeController::upgradeModules()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 28
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 22
nc 3
nop 0
dl 0
loc 28
rs 9.568
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula Foundation - https://ziku.la/
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 Zikula\Bundle\CoreInstallerBundle\Controller;
15
16
use Symfony\Component\DependencyInjection\ContainerInterface;
17
use Symfony\Component\HttpFoundation\JsonResponse;
18
use Symfony\Component\HttpFoundation\Request;
19
use Zikula\Bundle\CoreBundle\YamlDumper;
20
use Zikula\Bundle\CoreInstallerBundle\Helper\ParameterHelper;
21
use Zikula\Bundle\CoreInstallerBundle\Helper\StageHelper;
22
23
/**
24
 * Class AjaxUpgradeController
25
 */
26
class AjaxUpgradeController extends AbstractController
27
{
28
    /**
29
     * @var YamlDumper
30
     */
31
    private $yamlManager;
32
33
    /**
34
     * @var StageHelper
35
     */
36
    private $stageHelper;
37
38
    public function __construct(ContainerInterface $container)
39
    {
40
        parent::__construct($container);
41
        $this->yamlManager = $container->get(ParameterHelper::class)->getYamlManager();
42
        $this->stageHelper = $container->get(StageHelper::class);
43
    }
44
45
    public function ajaxAction(Request $request): JsonResponse
46
    {
47
        $stage = $request->request->get('stage');
48
        $this->yamlManager->setParameter('upgrading', true);
49
        $status = $this->stageHelper->executeStage($stage);
50
51
        return new JsonResponse(['status' => $status]);
52
    }
53
}
54