Skip to content

Commit c2b31b0

Browse files
committed
refactor: migrated privacy redirect (#3834)
1 parent 4182bee commit c2b31b0

File tree

6 files changed

+55
-38
lines changed

6 files changed

+55
-38
lines changed

phpmyfaq/assets/templates/default/index.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
{% if not isMaintenanceMode %}
174174
{% if isPrivacyLinkEnabled %}
175175
<li class="nav-item">
176-
<a class="nav-link d-inline-block px-0 pt-1 pb-2" target="_blank" href="{{ urlPrivacyLink }}">
176+
<a class="nav-link d-inline-block px-0 pt-1 pb-2" target="_blank" href="./privacy.html">
177177
{{ msgPrivacyNote }}
178178
</a>
179179
</li>

phpmyfaq/index.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@
639639
'isOpenQuestionsEnabled' => $faqConfig->get('main.enableAskQuestions'),
640640
'footerNavigation' => $footerNavigation,
641641
'isPrivacyLinkEnabled' => $faqConfig->get('layout.enablePrivacyLink'),
642-
'urlPrivacyLink' => $faqConfig->get('main.privacyURL'),
643642
'msgPrivacyNote' => Translation::get(key: 'msgPrivacyNote'),
644643
'isCookieConsentEnabled' => $faqConfig->get('layout.enableCookieConsent'),
645644
'cookiePreferences' => Translation::get(key: 'cookiePreferences'),

phpmyfaq/privacy.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

phpmyfaq/src/phpMyFAQ/Controller/Frontend/AbstractFrontController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ protected function getHeader(Request $request): array
101101
'isOpenQuestionsEnabled' => $this->configuration->get('main.enableAskQuestions'),
102102
'footerNavigation' => $this->getFooterNavigation($request),
103103
'isPrivacyLinkEnabled' => $this->configuration->get('layout.enablePrivacyLink'),
104-
'urlPrivacyLink' => $this->configuration->get('main.privacyURL'),
105104
'msgPrivacyNote' => Translation::get(key: 'msgPrivacyNote'),
106105
'isCookieConsentEnabled' => $this->configuration->get('layout.enableCookieConsent'),
107106
'cookiePreferences' => Translation::get(key: 'cookiePreferences'),
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/**
4+
* Privacy 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 <[email protected]>
12+
* @copyright 2023-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 2023-01-22
16+
*/
17+
18+
declare(strict_types=1);
19+
20+
namespace phpMyFAQ\Controller\Frontend;
21+
22+
use Symfony\Component\HttpFoundation\RedirectResponse;
23+
use Symfony\Component\HttpFoundation\Request;
24+
use Symfony\Component\HttpFoundation\Response;
25+
use Symfony\Component\Routing\Attribute\Route;
26+
27+
final class PrivacyController extends AbstractFrontController
28+
{
29+
/**
30+
* Redirects to the privacy page stored in the configuration.
31+
* @throws \Exception
32+
*/
33+
#[Route(path: '/privacy.html', name: 'public.privacy')]
34+
public function index(Request $request): Response
35+
{
36+
$privacyUrl = $this->configuration->get('main.privacyURL');
37+
$redirectUrl = strlen((string) $privacyUrl) > 0 ? $privacyUrl : $this->configuration->get('main.referenceURL');
38+
39+
return new RedirectResponse($redirectUrl);
40+
}
41+
}

phpmyfaq/src/public-routes.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@
1818
declare(strict_types=1);
1919

2020
use phpMyFAQ\Controller\Frontend\Api\SetupController;
21-
use phpMyFAQ\Controller\Frontend\AttachmentController;use phpMyFAQ\Controller\Frontend\ContactController;
22-
use phpMyFAQ\Controller\Frontend\GlossaryController;use phpMyFAQ\Controller\Frontend\LoginController;use phpMyFAQ\Controller\Frontend\OverviewController;
21+
use phpMyFAQ\Controller\Frontend\AttachmentController;
22+
use phpMyFAQ\Controller\Frontend\ContactController;
23+
use phpMyFAQ\Controller\Frontend\GlossaryController;
24+
use phpMyFAQ\Controller\Frontend\LoginController;
25+
use phpMyFAQ\Controller\Frontend\OverviewController;
2326
use phpMyFAQ\Controller\Frontend\PageNotFoundController;
24-
use phpMyFAQ\Controller\Frontend\PdfController;use phpMyFAQ\Controller\Frontend\SitemapController as FrontendSitemapController;
27+
use phpMyFAQ\Controller\Frontend\PdfController;
28+
use phpMyFAQ\Controller\Frontend\PrivacyController;
29+
use phpMyFAQ\Controller\Frontend\SitemapController as FrontendSitemapController;
2530
use phpMyFAQ\Controller\Frontend\WebAuthnController;
2631
use phpMyFAQ\Controller\LlmsController;
2732
use phpMyFAQ\Controller\RobotsController;
@@ -67,6 +72,11 @@
6772
'controller' => [PdfController::class, 'index'],
6873
'methods' => 'GET',
6974
],
75+
'public.privacy' => [
76+
'path' => '/privacy.html',
77+
'controller' => [PrivacyController::class, 'index'],
78+
'methods' => 'GET',
79+
],
7080
'public.sitemap' => [
7181
'path' => '/sitemap/{letter}/{language}.html',
7282
'controller' => [FrontendSitemapController::class, 'index'],

0 commit comments

Comments
 (0)