|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Contact 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 2015-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 2015-09-27 |
| 16 | + */ |
| 17 | + |
| 18 | +namespace phpMyFAQ\Controller\Frontend; |
| 19 | + |
| 20 | +use phpMyFAQ\Category; |
| 21 | +use phpMyFAQ\Core\Exception; |
| 22 | +use phpMyFAQ\Translation; |
| 23 | +use phpMyFAQ\Twig\Extensions\CategoryNameTwigExtension; |
| 24 | +use phpMyFAQ\Twig\Extensions\CreateLinkTwigExtension; |
| 25 | +use phpMyFAQ\Twig\Extensions\FaqTwigExtension; |
| 26 | +use phpMyFAQ\User\CurrentUser; |
| 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 | +use Twig\Extension\AttributeExtension; |
| 32 | + |
| 33 | +class OverviewController extends AbstractFrontController |
| 34 | +{ |
| 35 | + /** |
| 36 | + * @throws Exception |
| 37 | + * @throws LoaderError |
| 38 | + * @throws \Exception |
| 39 | + */ #[Route(path: '/overview.html', name: 'public.overview')] |
| 40 | + public function index(Request $request): Response |
| 41 | + { |
| 42 | + $faqSession = $this->container->get('phpmyfaq.user.session'); |
| 43 | + $faqSession->setCurrentUser($this->currentUser); |
| 44 | + $faqSession->userTracking('overview', 0); |
| 45 | + |
| 46 | + $faqHelper = $this->container->get('phpmyfaq.helper.faq'); |
| 47 | + |
| 48 | + [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
| 49 | + |
| 50 | + $category = new Category($this->configuration, $currentGroups, true); |
| 51 | + $category->setUser($currentUser)->setGroups($currentGroups); |
| 52 | + |
| 53 | + $faq = $this->container->get('phpmyfaq.faq'); |
| 54 | + $faq->setUser($currentUser); |
| 55 | + $faq->setGroups($currentGroups); |
| 56 | + |
| 57 | + $this->addExtension(new AttributeExtension(CategoryNameTwigExtension::class)); |
| 58 | + $this->addExtension(new AttributeExtension(CreateLinkTwigExtension::class)); |
| 59 | + $this->addExtension(new AttributeExtension(FaqTwigExtension::class)); |
| 60 | + return $this->render('overview.twig', [ |
| 61 | + ...$this->getHeader($request), |
| 62 | + 'title' => sprintf('%s - %s', Translation::get(key: 'faqOverview'), $this->configuration->getTitle()), |
| 63 | + 'metaDescription' => sprintf( |
| 64 | + Translation::get(key: 'msgOverviewMetaDesc'), |
| 65 | + $this->configuration->getTitle(), |
| 66 | + ), |
| 67 | + 'pageHeader' => Translation::get(key: 'faqOverview'), |
| 68 | + 'faqOverview' => $faqHelper->createOverview( |
| 69 | + $category, |
| 70 | + $faq, |
| 71 | + $this->configuration->getLanguage()->getLanguage(), |
| 72 | + ), |
| 73 | + 'msgAuthor' => Translation::get(key: 'msgAuthor'), |
| 74 | + 'msgLastUpdateArticle' => Translation::get(key: 'msgLastUpdateArticle'), |
| 75 | + ]); |
| 76 | + } |
| 77 | +} |
0 commit comments