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