TYPO3 CMS  TYPO3_7-6
EidUtility.php
Go to the documentation of this file.
1 <?php
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 
23 
34 {
41  public static function initFeUser()
42  {
43  // Get TSFE instance. It knows how to initialize the user. We also
44  // need TCA because services may need extra tables!
45  self::initTCA();
47  $tsfe = self::getTSFE();
48  $tsfe->initFEuser();
49  // Return FE user object:
50  return $tsfe->fe_user;
51  }
52 
59  public static function initLanguage($language = 'default')
60  {
61  if (!is_object($GLOBALS['LANG'])) {
62  $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
63  $GLOBALS['LANG']->init($language);
64  }
65  }
66 
72  public static function initTCA()
73  {
74  // Some badly made extensions attempt to manipulate TCA in a wrong way
75  // (inside ext_localconf.php). Therefore $GLOBALS['TCA'] may become an array
76  // but in fact it is not loaded. The check below ensure that
77  // TCA is still loaded if such bad extensions are installed
78  if (!is_array($GLOBALS['TCA']) || !isset($GLOBALS['TCA']['pages'])) {
79  Bootstrap::getInstance()->loadCachedTca();
80  }
81  }
82 
90  public static function initExtensionTCA($extensionKey)
91  {
92  $extTablesPath = ExtensionManagementUtility::extPath($extensionKey, 'ext_tables.php');
93  if (file_exists($extTablesPath)) {
94  $GLOBALS['_EXTKEY'] = $extensionKey;
95  require_once $extTablesPath;
96  // We do not need to save restore the value of $GLOBALS['_EXTKEY']
97  // because it is not defined to anything real outside of
98  // ext_tables.php or ext_localconf.php scope.
99  unset($GLOBALS['_EXTKEY']);
100  }
101  }
102 
108  private static function getTSFE()
109  {
110  // Cached instance
111  static $tsfe = null;
112  if (is_null($tsfe)) {
113  $tsfe = GeneralUtility::makeInstance(TypoScriptFrontendController::class, $GLOBALS['TYPO3_CONF_VARS'], 0, 0);
114  }
115  return $tsfe;
116  }
117 }
static initExtensionTCA($extensionKey)
Definition: EidUtility.php:90
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static initLanguage($language='default')
Definition: EidUtility.php:59