ModuleLoader
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);
Table of Contents
Properties
- $BE_USER : BackendUserAuthentication
 - The backend user for use internally
 - $modListGroup : array<string|int, mixed>
 - This array will hold the elements that should go into the select-list of modules for groups.
 - $modListUser : array<string|int, mixed>
 - This array will hold the elements that should go into the select-list of modules for users.
 - $modules : array<string, array<string|int, mixed>|bool|string>
 - After the init() function this array will contain the structure of available modules for the backend user.
 - $observeWorkspaces : bool
 - If set TRUE, workspace "permissions" will be observed so non-allowed modules will not be included in the array of modules.
 - $moduleLabels : array<string|int, mixed>
 - Labels for the modules
 - $navigationComponents : array<string|int, mixed>
 - Contains the registered navigation components
 
Methods
- addLabelsForModule() : mixed
 - Registers labels for a module in a unified way.
 - checkMod() : string|bool|array<string|int, mixed>
 - Here we check for the module.
 - checkModAccess() : bool
 - Returns TRUE if the internal BE_USER has access to the module $name with $MCONF (based on security level set for that module)
 - checkModWorkspace() : bool
 - Check if a module is allowed inside the current workspace for be user Processing happens only if $this->observeWorkspaces is TRUE
 - cleanName() : string
 - The $str is cleaned so that it contains alphanumerical characters only.
 - getLabelsForModule() : array<string|int, mixed>
 - Returns the labels for the given module
 - getModules() : array<string, array<string|int, mixed>|bool|string>
 - load() : mixed
 - Init.
 - parseModulesArray() : array<string, int|string>
 - Parses the moduleArray ($TBE_MODULES) into an internally useful structure.
 - getLanguageService() : LanguageService
 - getModuleSetupInformation() : array<string|int, mixed>
 - fetches the conf.php file of a certain module, and also merges that with some additional configuration
 
Properties
$BE_USER
The backend user for use internally
        public
            BackendUserAuthentication
    $BE_USER
    
    
    
    
    
    
$modListGroup
This array will hold the elements that should go into the select-list of modules for groups.
        public
            array<string|int, mixed>
    $modListGroup
     = []
        ..
$modListUser
This array will hold the elements that should go into the select-list of modules for users.
        public
            array<string|int, mixed>
    $modListUser
     = []
        ..
$modules
After the init() function this array will contain the structure of available modules for the backend user.
        public
            array<string, array<string|int, mixed>|bool|string>
    $modules
     = []
    
    
    
                        Tags
$observeWorkspaces
If set TRUE, workspace "permissions" will be observed so non-allowed modules will not be included in the array of modules.
        public
            bool
    $observeWorkspaces
     = false
    
    
    
    
    
$moduleLabels
Labels for the modules
        protected
            array<string|int, mixed>
    $moduleLabels
     = []
    
    
    
    
    
$navigationComponents
Contains the registered navigation components
        protected
            array<string|int, mixed>
    $navigationComponents
     = []
    
    
    
    
    
Methods
addLabelsForModule()
Registers labels for a module in a unified way.
    public
                    addLabelsForModule(string $moduleName, string|array<string|int, mixed> $labels) : mixed
    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
- $moduleName : string
 - 
                    
the name of the module
 - $labels : string|array<string|int, mixed>
 - 
                    
the information about the three labels
 
checkMod()
Here we check for the module.
    public
                    checkMod(string $name) : string|bool|array<string|int, mixed>
    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
- $name : string
 - 
                    
Module name
 
Return values
string|bool|array<string|int, mixed> —See description of function
checkModAccess()
Returns TRUE if the internal BE_USER has access to the module $name with $MCONF (based on security level set for that module)
    public
                    checkModAccess(string $name, array<string|int, mixed> $MCONF) : bool
    Parameters
- $name : string
 - 
                    
Module name
 - $MCONF : array<string|int, mixed>
 - 
                    
MCONF array (module configuration array) from the modules conf.php file (contains settings about what access level the module has)
 
Return values
bool —TRUE if access is granted for $this->BE_USER
checkModWorkspace()
Check if a module is allowed inside the current workspace for be user Processing happens only if $this->observeWorkspaces is TRUE
    public
                    checkModWorkspace(string $name, array<string|int, mixed> $MCONF) : bool
    Parameters
- $name : string
 - 
                    
Module name (unused)
 - $MCONF : array<string|int, mixed>
 - 
                    
MCONF array (module configuration array) from the modules conf.php file (contains settings about workspace restrictions)
 
Return values
bool —TRUE if access is granted for $this->BE_USER
cleanName()
The $str is cleaned so that it contains alphanumerical characters only.
    public
                    cleanName(string $str) : string
    Module names must only consist of these characters
Parameters
- $str : string
 - 
                    
String to clean up
 
Return values
stringgetLabelsForModule()
Returns the labels for the given module
    public
                    getLabelsForModule(string $moduleName) : array<string|int, mixed>
    Parameters
- $moduleName : string
 
Return values
array<string|int, mixed>getModules()
    public
                    getModules() : array<string, array<string|int, mixed>|bool|string>
    Return values
array<string, array<string|int, mixed>|bool|string>load()
Init.
    public
                    load(array<string|int, mixed> $modulesArray[, BackendUserAuthentication $beUser = null ]) : mixed
    The outcome of the load() function will be a $this->modules array populated with the backend module structure available to the BE_USER Further the global var $LANG will have labels and images for the modules loaded in an internal array.
Parameters
- $modulesArray : array<string|int, mixed>
 - 
                    
Should be the global var $TBE_MODULES, $BE_USER can optionally be set to an alternative Backend user object than the global var $BE_USER (which is the currently logged in user)
 - $beUser : BackendUserAuthentication = null
 - 
                    
|null Optional backend user object to use. If not set, the global BE_USER object is used.
 
parseModulesArray()
Parses the moduleArray ($TBE_MODULES) into an internally useful structure.
    public
                    parseModulesArray(array<string|int, mixed> $arr) : array<string, int|string>
    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
- $arr : array<string|int, mixed>
 - 
                    
ModuleArray ($TBE_MODULES)
 
Return values
array<string, int|string> —Output structure with available modules
getLanguageService()
    protected
                    getLanguageService() : LanguageService
    Return values
LanguageServicegetModuleSetupInformation()
fetches the conf.php file of a certain module, and also merges that with some additional configuration
    protected
                    getModuleSetupInformation(string $moduleName) : array<string|int, mixed>
    Parameters
- $moduleName : string
 - 
                    
the combined name of the module, can be "web", "web_info", or "tools_log"
 
Return values
array<string|int, mixed> —an array with subarrays, named "configuration" (aka $MCONF), "labels" (previously known as $MLANG) and the stripped path