TYPO3 CMS  TYPO3_8-7
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 
22 
33 {
40  public static function initFeUser()
41  {
42  // Get TSFE instance. It knows how to initialize the user. We also
43  // need TCA because services may need extra tables!
44  self::initTCA();
46  $tsfe = self::getTSFE();
47  $tsfe->initFEuser();
48  // Return FE user object:
49  return $tsfe->fe_user;
50  }
51 
57  public static function initLanguage($language = 'default')
58  {
59  if (!is_object($GLOBALS['LANG'])) {
60  $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
61  $GLOBALS['LANG']->init($language);
62  }
63  }
64 
68  public static function initTCA()
69  {
70  // Some badly made extensions attempt to manipulate TCA in a wrong way
71  // (inside ext_localconf.php). Therefore $GLOBALS['TCA'] may become an array
72  // but in fact it is not loaded. The check below ensure that
73  // TCA is still loaded if such bad extensions are installed
74  if (!is_array($GLOBALS['TCA']) || !isset($GLOBALS['TCA']['pages'])) {
75  ExtensionManagementUtility::loadBaseTca();
76  }
77  }
78 
85  public static function initExtensionTCA($extensionKey)
86  {
87  $extTablesPath = ExtensionManagementUtility::extPath($extensionKey, 'ext_tables.php');
88  if (file_exists($extTablesPath)) {
89  $GLOBALS['_EXTKEY'] = $extensionKey;
90  require_once $extTablesPath;
91  // We do not need to save restore the value of $GLOBALS['_EXTKEY']
92  // because it is not defined to anything real outside of
93  // ext_tables.php or ext_localconf.php scope.
94  unset($GLOBALS['_EXTKEY']);
95  }
96  }
97 
103  private static function getTSFE()
104  {
105  // Cached instance
106  static $tsfe = null;
107  if (is_null($tsfe)) {
108  $tsfe = GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, 0, 0);
109  }
110  return $tsfe;
111  }
112 }
static initExtensionTCA($extensionKey)
Definition: EidUtility.php:85
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static initLanguage($language='default')
Definition: EidUtility.php:57