a2fbef86377e3f243031565f245d3e000e6e5d76
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Http / EidRequestHandler.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Http;
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\Core\Bootstrap;
18 use TYPO3\CMS\Core\TimeTracker\NullTimeTracker;
19 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
20 use TYPO3\CMS\Frontend\Utility\EidUtility;
21 use TYPO3\CMS\Core\Utility\GeneralUtility;
22 use TYPO3\CMS\Core\Core\RequestHandlerInterface;
23
24 /**
25 * Lightweight alternative to the regular RequestHandler used when $_GET[eID] is set.
26 * In the future, logic from the EidUtility will be moved to this class.
27 */
28 class EidRequestHandler implements RequestHandlerInterface {
29
30 /**
31 * Instance of the current TYPO3 bootstrap
32 * @var Bootstrap
33 */
34 protected $bootstrap;
35
36 /**
37 * Constructor handing over the bootstrap
38 *
39 * @param Bootstrap $bootstrap
40 */
41 public function __construct(Bootstrap $bootstrap) {
42 $this->bootstrap = $bootstrap;
43 }
44
45 /**
46 * Handles a frontend request based on the _GP "eID" variable.
47 *
48 * @return void
49 */
50 public function handleRequest() {
51 // Timetracking started
52 $configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']);
53 if (empty($configuredCookieName)) {
54 $configuredCookieName = 'be_typo_user';
55 }
56 if ($_COOKIE[$configuredCookieName]) {
57 $GLOBALS['TT'] = new TimeTracker();
58 } else {
59 $GLOBALS['TT'] = new NullTimeTracker();
60 }
61
62 $GLOBALS['TT']->start();
63
64 // Hook to preprocess the current request
65 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
66 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
67 $hookParameters = array();
68 GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters);
69 }
70 unset($hookFunction);
71 unset($hookParameters);
72 }
73
74 // Remove any output produced until now
75 $this->bootstrap->endOutputBufferingAndCleanPreviousOutput();
76 require EidUtility::getEidScriptPath();
77 $this->bootstrap->shutdown();
78 exit;
79 }
80
81 /**
82 * This request handler can handle any frontend request.
83 *
84 * @return bool If the request is not an eID request, TRUE otherwise FALSE
85 */
86 public function canHandleRequest() {
87 return GeneralUtility::_GP('eID') ? TRUE : FALSE;
88 }
89
90 /**
91 * Returns the priority - how eager the handler is to actually handle the
92 * request.
93 *
94 * @return int The priority of the request handler.
95 */
96 public function getPriority() {
97 return 80;
98 }
99 }