Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| StopWordsController | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| index | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The Administration Stop Words 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 2024-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 2024-11-22 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace phpMyFAQ\Controller\Administration; |
| 21 | |
| 22 | use phpMyFAQ\Core\Exception; |
| 23 | use phpMyFAQ\Enums\PermissionType; |
| 24 | use phpMyFAQ\Language\LanguageCodes; |
| 25 | use phpMyFAQ\Session\Token; |
| 26 | use phpMyFAQ\Translation; |
| 27 | use Symfony\Component\HttpFoundation\Request; |
| 28 | use Symfony\Component\HttpFoundation\Response; |
| 29 | use Symfony\Component\Routing\Attribute\Route; |
| 30 | use Twig\Error\LoaderError; |
| 31 | |
| 32 | final class StopWordsController extends AbstractAdministrationController |
| 33 | { |
| 34 | /** |
| 35 | * @throws LoaderError |
| 36 | * @throws Exception |
| 37 | * @throws \Exception |
| 38 | */ |
| 39 | #[Route(path: '/stopwords', name: 'admin.stopwords', methods: ['GET'])] |
| 40 | public function index(Request $request): Response |
| 41 | { |
| 42 | $this->userHasPermission(PermissionType::CONFIGURATION_EDIT); |
| 43 | |
| 44 | $hasPermission = $this->currentUser?->perm->hasPermission( |
| 45 | $this->currentUser->getUserId(), |
| 46 | PermissionType::CONFIGURATION_EDIT, |
| 47 | ); |
| 48 | |
| 49 | return $this->render('@admin/configuration/stopwords.twig', [ |
| 50 | ...$this->getHeader($request), |
| 51 | ...$this->getFooter(), |
| 52 | 'adminHeaderStopWords' => Translation::get(key: 'ad_menu_stopwordsconfig'), |
| 53 | 'hasPermission' => $hasPermission, |
| 54 | 'msgDescription' => Translation::get(key: 'ad_stopwords_desc'), |
| 55 | 'csrfToken' => Token::getInstance($this->session)->getTokenInput('stopwords'), |
| 56 | 'msgStopWordsLabel' => Translation::get(key: 'ad_stopwords_desc'), |
| 57 | 'sortedLanguageCodes' => LanguageCodes::getAllSorted(), |
| 58 | 'buttonAdd' => Translation::get(key: 'ad_config_stopword_input'), |
| 59 | ]); |
| 60 | } |
| 61 | } |