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

PhpConfigController::index()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 18
rs 9.9
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