Lines 100.00% 8 / 8
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
AboutController 100.00% 8 / 8 100.00% 1 / 1 1 100.00% 1 / 1
 __invoke 100.00% 8 / 8 100.00% 1 / 1 1
1<?php
2
3namespace App\Controller\System;
4
5use App\Controller\BaseController;
6use App\Enum\UserRole;
7use Symfony\Bundle\FrameworkBundle\Console\Application;
8use Symfony\Component\Console\Input\ArrayInput;
9use Symfony\Component\Console\Output\BufferedOutput;
10use Symfony\Component\DependencyInjection\Attribute\Autowire;
11use Symfony\Component\HttpFoundation\Response;
12use Symfony\Component\HttpKernel\KernelInterface;
13use Symfony\Component\Routing\Attribute\Route;
14use Symfony\Component\Security\Http\Attribute\IsGranted;
15
16#[Route('/system/about', name: 'app_system_about', methods: ['GET'])]
17#[IsGranted(UserRole::ADMIN->value)]
18class AboutController extends BaseController
19{
20    public function __invoke(
21        #[Autowire('%kernel.project_dir%')] string $projectDir,
22        KernelInterface $kernel
23    ): Response {
24        $output = new BufferedOutput();
25
26        $application = new Application($kernel);
27        $application->setAutoExit(false);
28        $application->run(new ArrayInput(['command' => 'about']), $output);
29
30        return $this->render('system/about.html.twig', [
31            'project_dir' => $projectDir,
32            'systemInfo' => $output->fetch(),
33        ]);
34    }
35}