[TASK] Removes extra empty lines
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Page / ExternalPageUrlHandler.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Page;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\HttpUtility;
18
19 /**
20 * Handles the redirection for external URL pages.
21 */
22 class ExternalPageUrlHandler implements \TYPO3\CMS\Frontend\Http\UrlHandlerInterface
23 {
24 /**
25 * @var string
26 */
27 protected $externalUrl = '';
28
29 /**
30 * Checks if external URLs are enabled and if the current page points to an external URL.
31 *
32 * @return bool
33 */
34 public function canHandleCurrentUrl()
35 {
36 $tsfe = $this->getTypoScriptFrontendController();
37
38 if (!empty($tsfe->config['config']['disablePageExternalUrl'])) {
39 return false;
40 }
41
42 $this->externalUrl = $tsfe->sys_page->getExtURL($tsfe->page);
43 if (empty($this->externalUrl)) {
44 return false;
45 } else {
46 return true;
47 }
48 }
49
50 /**
51 * Redirects the user to the detected external URL.
52 *
53 * @return void
54 */
55 public function handle()
56 {
57 HttpUtility::redirect($this->externalUrl, HttpUtility::HTTP_STATUS_303);
58 }
59
60 /**
61 * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
62 */
63 protected function getTypoScriptFrontendController()
64 {
65 return $GLOBALS['TSFE'];
66 }
67 }