Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| OrphanedFaqsController | |
100.00% |
9 / 9 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| index | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The Orphaned FAQs 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-03-02 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace phpMyFAQ\Controller\Administration; |
| 21 | |
| 22 | use phpMyFAQ\Administration\Faq as AdminFaq; |
| 23 | use phpMyFAQ\Core\Exception; |
| 24 | use phpMyFAQ\Enums\PermissionType; |
| 25 | use phpMyFAQ\Twig\Extensions\LanguageCodeTwigExtension; |
| 26 | use Symfony\Component\HttpFoundation\Request; |
| 27 | use Symfony\Component\HttpFoundation\Response; |
| 28 | use Symfony\Component\Routing\Attribute\Route; |
| 29 | use Twig\Error\LoaderError; |
| 30 | use Twig\Extension\AttributeExtension; |
| 31 | |
| 32 | final class OrphanedFaqsController extends AbstractAdministrationController |
| 33 | { |
| 34 | public function __construct( |
| 35 | private readonly AdminFaq $adminFaq, |
| 36 | ) { |
| 37 | parent::__construct(); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @throws Exception |
| 42 | * @throws LoaderError |
| 43 | * @throws \Exception |
| 44 | */ |
| 45 | #[Route(path: '/orphaned-faqs', name: 'admin.content.orphaned-faqs', methods: ['GET'])] |
| 46 | public function index(Request $request): Response |
| 47 | { |
| 48 | $this->userHasPermission(PermissionType::FAQ_EDIT); |
| 49 | |
| 50 | $faq = $this->adminFaq; |
| 51 | |
| 52 | $this->addExtension(new AttributeExtension(LanguageCodeTwigExtension::class)); |
| 53 | |
| 54 | return $this->render('@admin/content/orphaned-faqs.twig', [ |
| 55 | ...$this->getHeader($request), |
| 56 | ...$this->getFooter(), |
| 57 | 'orphanedFaqs' => $faq->getOrphanedFaqs(), |
| 58 | ]); |
| 59 | } |
| 60 | } |