Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PluginController
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 index
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * The Plugin Controller
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package   phpMyFAQ
11 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
12 * @copyright 2025-2026 phpMyFAQ Team
13 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14 * @link      https://www.phpmyfaq.de
15 * @since     2025-01-18
16 */
17
18declare(strict_types=1);
19
20namespace phpMyFAQ\Controller\Administration;
21
22use phpMyFAQ\Core\Exception;
23use phpMyFAQ\Enums\PermissionType;
24use phpMyFAQ\Plugin\PluginManager;
25use Symfony\Component\HttpFoundation\Request;
26use Symfony\Component\HttpFoundation\Response;
27use Symfony\Component\Routing\Attribute\Route;
28use Twig\Error\LoaderError;
29
30final class PluginController extends AbstractAdministrationController
31{
32    public function __construct(
33        private readonly PluginManager $pluginManager,
34    ) {
35        parent::__construct();
36    }
37
38    /**
39     * @throws LoaderError
40     * @throws Exception
41     * @throws \Exception
42     */
43    #[Route(path: '/plugins', name: 'admin.configuration.plugins', methods: ['GET'])]
44    public function index(Request $request): Response
45    {
46        $this->userHasPermission(PermissionType::CONFIGURATION_EDIT);
47
48        $pluginManager = $this->pluginManager;
49        $pluginManager->loadPlugins();
50
51        return $this->render('@admin/configuration/plugins.twig', [
52            ...$this->getHeader($request),
53            ...$this->getFooter(),
54            'pluginList' => $pluginManager->getPlugins(),
55            'incompatiblePlugins' => $pluginManager->getIncompatiblePlugins(),
56        ]);
57    }
58}