| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | namespace Aoe\Restler\System\TYPO3; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | /*************************************************************** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  *  Copyright notice | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  *  (c) 2015 AOE GmbH <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  *  All rights reserved | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  *  This script is part of the TYPO3 project. The TYPO3 project is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  *  free software; you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  *  it under the terms of the GNU General Public License as published by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  *  the Free Software Foundation; either version 3 of the License, or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  *  (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  *  The GNU General Public License can be found at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  *  http://www.gnu.org/copyleft/gpl.html. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  *  This script is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  *  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  *  GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  *  This copyright notice MUST APPEAR in all copies of the script! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  ***************************************************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use TYPO3\CMS\Core\Core\Bootstrap; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use TYPO3\CMS\Core\SingletonInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use TYPO3\CMS\Core\TimeTracker\NullTimeTracker; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use TYPO3\CMS\Core\Utility\GeneralUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use TYPO3\CMS\Frontend\Utility\EidUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | use LogicException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  * @package Restler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | class Loader implements SingletonInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * defines, if usage of backend-user is enabled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @var boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     private $isBackEndUserInitialized = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * defines, if usage of frontend-user is enabled (this is needed, if the eID-script must determine the frontend-user) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @var boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     private $isFrontEndUserInitialized = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * defines, if frontend-rendering is enabled (this is needed, if the eID-script must render some content-elements or RTE-fields) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @var boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     private $isFrontEndRenderingInitialized = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @return BackendUserAuthentication | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @throws LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     public function getBackEndUser() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         if ($this->isBackEndUserInitialized === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             throw new LogicException('be-user is not initialized - initialize with BE-user with method \'initializeBackendEndUser\''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         return $GLOBALS['BE_USER']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @return FrontendUserAuthentication | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @throws LogicException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function getFrontEndUser() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         if ($this->isFrontEndUserInitialized === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             throw new LogicException('fe-user is not initialized - initialize with FE-user with method \'initializeFrontEndUser\''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         return $GLOBALS['TSFE']->fe_user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * enable the usage of backend-user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     public function initializeBackendEndUser() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         if(!class_exists('\TYPO3\CMS\Core\Configuration\ExtensionConfiguration')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             if ($this->isBackEndUserInitialized === true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                 return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             $bootstrapObj = Bootstrap::getInstance(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             $bootstrapObj->loadExtensionTables(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             $bootstrapObj->initializeBackendUser(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             $bootstrapObj->initializeBackendAuthentication(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             $bootstrapObj->initializeLanguageObject(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $this->isBackEndUserInitialized = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * enable the usage of frontend-user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @param integer $pageId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @param integer $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     public function initializeFrontEndUser($pageId = 0, $type = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         if(!class_exists('\TYPO3\CMS\Core\Configuration\ExtensionConfiguration')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             if (array_key_exists('TSFE', $GLOBALS) && is_object($GLOBALS['TSFE']->fe_user)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                 // FE-user is already initialized - this can happen when we use/call internal REST-endpoints inside of a normal TYPO3-page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                 $this->isFrontEndUserInitialized = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             if ($this->isFrontEndUserInitialized === true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             $tsfe = $this->getTsfe($pageId, $type); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |             $tsfe->initFEUser(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->isFrontEndUserInitialized = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * enable the frontend-rendering | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * @param integer $pageId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @param integer $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * @return void | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 137 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |     public function initializeFrontEndRendering($pageId = 0, $type = 0) | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |         if(!class_exists('\TYPO3\CMS\Core\Configuration\ExtensionConfiguration')) { | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |             if (array_key_exists('TSFE', $GLOBALS) && is_object($GLOBALS['TSFE']->tmpl)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |                 // FE is already initialized - this can happen when we use/call internal REST-endpoints inside of a normal TYPO3-page | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |                 $this->isFrontEndRenderingInitialized = true; | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |             if ($this->isFrontEndRenderingInitialized === true) { | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |                 return; | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |             $GLOBALS['TT'] = new NullTimeTracker(); | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  |             if ($this->isFrontEndUserInitialized === false) { | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |                 $this->initializeFrontEndUser($pageId, $type); | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |             EidUtility::initTCA(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  |             $tsfe = $this->getTsfe($pageId, $type); | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |             $tsfe->determineId(); | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |             $tsfe->initTemplate(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  |             $tsfe->getConfigArray(); | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |             $tsfe->newCObj(); | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |             $tsfe->calculateLinkVars(); | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |         $this->isFrontEndRenderingInitialized = true; | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * @param integer $pageId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @param integer $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @return TypoScriptFrontendController | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     private function getTsfe($pageId, $type = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         if ($type > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             $_GET['type'] = $type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         if (false === array_key_exists('TSFE', $GLOBALS)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             $GLOBALS['TSFE'] = GeneralUtility::makeInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |                 $GLOBALS['TYPO3_CONF_VARS'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |                 $pageId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |                 $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         return $GLOBALS['TSFE']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 188 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 189 |  |  |  | 
            
                        
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.