Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ImportController | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| index | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The Administration Import 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-23 |
| 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\Session\Token; |
| 25 | use phpMyFAQ\Translation; |
| 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 | |
| 31 | final class ImportController extends AbstractAdministrationController |
| 32 | { |
| 33 | /** |
| 34 | * @throws Exception |
| 35 | * @throws LoaderError |
| 36 | * @throws \Exception |
| 37 | */ |
| 38 | #[Route(path: '/import', name: 'admin.import', methods: ['GET'])] |
| 39 | public function index(Request $request): Response |
| 40 | { |
| 41 | $this->userHasPermission(PermissionType::FAQ_ADD); |
| 42 | |
| 43 | return $this->render('@admin/import-export/import.twig', [ |
| 44 | ...$this->getHeader($request), |
| 45 | ...$this->getFooter(), |
| 46 | 'adminHeaderImport' => Translation::get(key: 'msgImportRecords'), |
| 47 | 'adminHeaderCSVImport' => Translation::get(key: 'msgImportCSVFile'), |
| 48 | 'adminBodyCSVImport' => Translation::get(key: 'msgImportCSVFileBody'), |
| 49 | 'adminImportLabel' => Translation::get(key: 'ad_csv_file'), |
| 50 | 'adminCSVImport' => Translation::get(key: 'msgImport'), |
| 51 | 'adminHeaderCSVImportColumns' => Translation::get(key: 'msgColumnStructure'), |
| 52 | 'categoryId' => Translation::get(key: 'ad_categ_categ'), |
| 53 | 'question' => Translation::get(key: 'ad_entry_topic'), |
| 54 | 'languageCode' => Translation::get(key: 'msgLanguageCode'), |
| 55 | 'msgImportRecordsColumnStructure' => Translation::get(key: 'msgImportRecordsColumnStructure'), |
| 56 | 'csrfToken' => Token::getInstance($this->session)->getTokenString('importfaqs'), |
| 57 | 'is_active' => Translation::get(key: 'ad_entry_active'), |
| 58 | 'trueFalse' => Translation::get(key: 'msgCSVImportTrueOrFalse'), |
| 59 | ]); |
| 60 | } |
| 61 | } |