Passed
Push — 6.5.0.0 ( 85bd4e...fe6596 )
by Christian
24:46 queued 09:10
created

PhpConfigController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 18 4
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Controller;
5
6
use App\Services\PhpBinaryFinder;
7
use App\Services\RecoveryManager;
8
use Shopware\Core\Framework\Log\Package;
9
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\HttpFoundation\Response;
12
use Symfony\Component\Routing\Annotation\Route;
13
14
#[Package('core')]
15
16
/**
17
 * @internal
18
 */
19
class PhpConfigController extends AbstractController
20
{
21
    public function __construct(
22
        private readonly PhpBinaryFinder $binaryFinder,
23
        private readonly RecoveryManager $recoveryManager
24
    ) {
25
    }
26
27
    #[Route('/configure', name: 'configure', defaults: ['step' => 1])]
28
    public function index(Request $request): Response
29
    {
30
        try {
31
            $shopwareLocation = $this->recoveryManager->getShopwareLocation();
32
        } catch (\RuntimeException $e) {
33
            $shopwareLocation = null;
34
        }
35
36
        if ($phpBinary = $request->request->get('phpBinary')) {
37
            $request->getSession()->set('phpBinary', $phpBinary);
38
39
            return $this->redirectToRoute($shopwareLocation === null ? 'install' : 'update');
40
        }
41
42
        return $this->render('php_config.html.twig', [
43
            'phpBinary' => $request->getSession()->get('phpBinary', $this->binaryFinder->find()),
44
            'shopwareLocation' => $shopwareLocation,
45
        ]);
46
    }
47
}
48