‪TYPO3CMS  11.5
TYPO3\CMS\Backend\Module\ModuleLoader Class Reference

Public Member Functions

foreach($mainModules as $mainModuleName=> $subModules) string bool array checkMod ($name)
 
bool checkModAccess ($name, $MCONF)
 
bool checkModWorkspace ($name, $MCONF)
 
array< string, parseModulesArray( $arr) { $theMods=[];if(is_array( $arr)) { foreach( $arr as $mod=> $subs) { $mod=$this-> cleanName ($mod)
 
string cleanName ($str)
 
 addLabelsForModule ($moduleName, $labels)
 
array getLabelsForModule ($moduleName)
 

Public Attributes

array< string, $modules=array();public array $modListGroup=array();public array $modListUser=array();public \TYPO3\CMS\Core\Authentication\BackendUserAuthentication $BE_USER;public bool $observeWorkspaces=false;protected array $navigationComponents=array();protected array $moduleLabels=array();public array< string, function getModules():array { return $this->modules;} public function load( $modulesArray, ?BackendUserAuthentication $beUser=null) { $this-> BE_USER = $beUser ?: $GLOBALS['BE_USER']
 
$this navigationComponents = $modulesArray['_navigationComponents']
 
 $mainModules = $this->parseModulesArray($modulesArray)
 
if($mod) return $theMods
 

Protected Member Functions

array getModuleSetupInformation ($moduleName)
 
LanguageService getLanguageService ()
 

Detailed Description

This document provides a class that loads the modules for the TYPO3 interface.

Load Backend Interface modules

Typically instantiated like this: $this->loadModules = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Module\ModuleLoader::class); $this->loadModules->load($TBE_MODULES);

Definition at line 33 of file ModuleLoader.php.

Member Function Documentation

◆ addLabelsForModule()

TYPO3\CMS\Backend\Module\ModuleLoader::addLabelsForModule (   $moduleName,
  $labels 
)

Registers labels for a module in a unified way.

Legacy info: This was previously named

  • ‪labels->tablabel (now called "shortdescription")
  • ‪labels->tabdescr (now called "description")
  • ‪tabs->tab (now called "title")

The LLL information is stored, not the actual translated string.

Parameters
string$moduleName‪the name of the module
string | array$labels‪the information about the three labels

Definition at line 361 of file ModuleLoader.php.

References TYPO3\CMS\Backend\Module\ModuleLoader\getLanguageService().

Referenced by TYPO3\CMS\Backend\Module\ModuleLoader\checkMod().

◆ checkMod()

foreach ( $mainModules as $mainModuleName=> $subModules) string bool array TYPO3\CMS\Backend\Module\ModuleLoader::checkMod (   $name)

Here we check for the module.

Return values: 'notFound': If the module was not found in the path (no "conf.php" file) FALSE: If no access to the module (access check failed) array(): Configuration array, in case a valid module where access IS granted exists.

Parameters
string$nameModule name
Returns
‪string|bool|array See description of function

Definition at line 144 of file ModuleLoader.php.

References TYPO3\CMS\Backend\Module\ModuleLoader\addLabelsForModule(), TYPO3\CMS\Backend\Module\ModuleLoader\checkModAccess(), TYPO3\CMS\Backend\Module\ModuleLoader\checkModWorkspace(), TYPO3\CMS\Backend\Module\ModuleLoader\getModuleSetupInformation(), and TYPO3\CMS\Backend\Module\ModuleLoader\navigationComponents.

◆ checkModAccess()

bool TYPO3\CMS\Backend\Module\ModuleLoader::checkModAccess (   $name,
  $MCONF 
)

Returns TRUE if the internal BE_USER has access to the module $name with $MCONF (based on security level set for that module)

Parameters
string$nameModule name
array$MCONF‪MCONF array (module configuration array) from the modules conf.php file (contains settings about what access level the module has)
Returns
‪bool TRUE if access is granted for $this->BE_USER

Definition at line 252 of file ModuleLoader.php.

References TYPO3\CMS\Backend\Module\ModuleLoader\BE_USER, and TYPO3\CMS\Core\Authentication\BackendUserAuthentication\ROLE_SYSTEMMAINTAINER.

Referenced by TYPO3\CMS\Backend\Module\ModuleLoader\checkMod().

◆ checkModWorkspace()

bool TYPO3\CMS\Backend\Module\ModuleLoader::checkModWorkspace (   $name,
  $MCONF 
)

Check if a module is allowed inside the current workspace for be user Processing happens only if $this->observeWorkspaces is TRUE

Parameters
string$nameModule name (unused)
array$MCONF‪MCONF array (module configuration array) from the modules conf.php file (contains settings about workspace restrictions)
Returns
‪bool TRUE if access is granted for $this->BE_USER

Definition at line 289 of file ModuleLoader.php.

References TYPO3\CMS\Backend\Module\ModuleLoader\BE_USER.

Referenced by TYPO3\CMS\Backend\Module\ModuleLoader\checkMod().

◆ cleanName() [1/2]

array<string, parseModulesArray($arr) { $theMods = []; if (is_array($arr)) { foreach ($arr as $mod => $subs) { $mod = $this-> TYPO3\CMS\Backend\Module\ModuleLoader::cleanName (   $mod)

Parses the moduleArray ($TBE_MODULES) into an internally useful structure. Returns an array where the keys are names of the module and the values may be TRUE (only module) or an array (of submodules)

Parameters
array$arr‪ModuleArray ($TBE_MODULES)
Returns
‪array<string, int|string> Output structure with available modules

◆ cleanName() [2/2]

string TYPO3\CMS\Backend\Module\ModuleLoader::cleanName (   $str)

The $str is cleaned so that it contains alphanumerical characters only. Module names must only consist of these characters

Parameters
string$str‪String to clean up
Returns
‪string

Definition at line 343 of file ModuleLoader.php.

◆ getLabelsForModule()

array TYPO3\CMS\Backend\Module\ModuleLoader::getLabelsForModule (   $moduleName)

Returns the labels for the given module

Parameters
string$moduleName
Returns
‪array

Definition at line 405 of file ModuleLoader.php.

◆ getLanguageService()

LanguageService TYPO3\CMS\Backend\Module\ModuleLoader::getLanguageService ( )
protected
Returns
‪LanguageService

Definition at line 413 of file ModuleLoader.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Backend\Module\ModuleLoader\addLabelsForModule().

◆ getModuleSetupInformation()

array TYPO3\CMS\Backend\Module\ModuleLoader::getModuleSetupInformation (   $moduleName)
protected

fetches the conf.php file of a certain module, and also merges that with some additional configuration

Parameters
string$moduleName‪the combined name of the module, can be "web", "web_info", or "tools_log"
Returns
‪array an array with subarrays, named "configuration" (aka $MCONF), "labels" (previously known as $MLANG) and the stripped path

Definition at line 211 of file ModuleLoader.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Backend\Module\ModuleLoader\checkMod().

Member Data Documentation

◆ $mainModules

TYPO3\CMS\Backend\Module\ModuleLoader::$mainModules = $this->parseModulesArray($modulesArray)

Definition at line 104 of file ModuleLoader.php.

◆ $theMods

if ( $mod) return TYPO3\CMS\Backend\Module\ModuleLoader::$theMods

Definition at line 333 of file ModuleLoader.php.

◆ BE_USER

array<string, $modules = array( ); public array $modListGroup = array( ); public array $modListUser = array( ); public \TYPO3\CMS\Core\Authentication\BackendUserAuthentication $BE_USER; public bool $observeWorkspaces = false; protected array $navigationComponents = array( ); protected array $moduleLabels = array( ); public array<string, function getModules(): array { return $this->modules; } public function load($modulesArray, ?BackendUserAuthentication $beUser = null) { $this-> TYPO3\CMS\Backend\Module\ModuleLoader::BE_USER = $beUser ?: $GLOBALS['BE_USER']

After the init() function this array will contain the structure of available modules for the backend user.

array|bool|string>

Todo:
‪Restrict property visibility to protected in TYPO3 v12.0

Definition at line 98 of file ModuleLoader.php.

Referenced by TYPO3\CMS\Backend\Module\ModuleLoader\checkModAccess(), and TYPO3\CMS\Backend\Module\ModuleLoader\checkModWorkspace().

◆ navigationComponents

$this TYPO3\CMS\Backend\Module\ModuleLoader::navigationComponents = $modulesArray['_navigationComponents']

Definition at line 102 of file ModuleLoader.php.

Referenced by TYPO3\CMS\Backend\Module\ModuleLoader\checkMod().