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

Public Member Functions

 load ($modulesArray, BackendUserAuthentication $beUser=null)
 
string bool array checkMod ($name)
 
bool checkModAccess ($name, $MCONF)
 
bool checkModWorkspace ($name, $MCONF)
 
array parseModulesArray ($arr)
 
string cleanName ($str)
 
 addLabelsForModule ($moduleName, $labels)
 
array getLabelsForModule ($moduleName)
 

Public Attributes

array $modules = array( )
 
array $modListGroup = array( )
 
array $modListUser = array( )
 
TYPO3 CMS Core Authentication BackendUserAuthentication $BE_USER
 
bool $observeWorkspaces = false
 

Protected Member Functions

array getModuleSetupInformation ($moduleName)
 
LanguageService getLanguageService ()
 

Protected Attributes

array $navigationComponents = array( )
 
array $moduleLabels = array( )
 

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 346 of file ModuleLoader.php.

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

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

◆ checkMod()

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 133 of file ModuleLoader.php.

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

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

◆ 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 236 of file ModuleLoader.php.

References 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 273 of file ModuleLoader.php.

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

◆ cleanName()

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 328 of file ModuleLoader.php.

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

◆ getLabelsForModule()

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

Returns the labels for the given module

Parameters
string$moduleName
Returns
‪array

Definition at line 390 of file ModuleLoader.php.

Referenced by TYPO3\CMS\About\Controller\AboutController\getSubModuleData().

◆ getLanguageService()

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

Definition at line 398 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 195 of file ModuleLoader.php.

References $GLOBALS.

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

◆ load()

TYPO3\CMS\Backend\Module\ModuleLoader::load (   $modulesArray,
BackendUserAuthentication  $beUser = null 
)

Init. 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
array$modulesArray‪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)
BackendUserAuthentication$beUser‪Optional backend user object to use. If not set, the global BE_USER object is used.

Definition at line 84 of file ModuleLoader.php.

References $GLOBALS, TYPO3\CMS\Backend\Module\ModuleLoader\checkMod(), and TYPO3\CMS\Backend\Module\ModuleLoader\parseModulesArray().

◆ parseModulesArray()

array TYPO3\CMS\Backend\Module\ModuleLoader::parseModulesArray (   $arr)

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 Output structure with available modules

Definition at line 296 of file ModuleLoader.php.

References TYPO3\CMS\Backend\Module\ModuleLoader\cleanName(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

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

Member Data Documentation

◆ $BE_USER

TYPO3 CMS Core Authentication BackendUserAuthentication TYPO3\CMS\Backend\Module\ModuleLoader::$BE_USER

The backend user for use internally

Definition at line 57 of file ModuleLoader.php.

◆ $modListGroup

array TYPO3\CMS\Backend\Module\ModuleLoader::$modListGroup = array( )

This array will hold the elements that should go into the select-list of modules for groups...

Definition at line 45 of file ModuleLoader.php.

◆ $modListUser

array TYPO3\CMS\Backend\Module\ModuleLoader::$modListUser = array( )

This array will hold the elements that should go into the select-list of modules for users...

Definition at line 51 of file ModuleLoader.php.

◆ $moduleLabels

array TYPO3\CMS\Backend\Module\ModuleLoader::$moduleLabels = array( )
protected

Labels for the modules

Definition at line 74 of file ModuleLoader.php.

◆ $modules

array TYPO3\CMS\Backend\Module\ModuleLoader::$modules = array( )

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

Definition at line 39 of file ModuleLoader.php.

◆ $navigationComponents

array TYPO3\CMS\Backend\Module\ModuleLoader::$navigationComponents = array( )
protected

Contains the registered navigation components

Definition at line 69 of file ModuleLoader.php.

◆ $observeWorkspaces

bool TYPO3\CMS\Backend\Module\ModuleLoader::$observeWorkspaces = false

If set TRUE, workspace "permissions" will be observed so non-allowed modules will not be included in the array of modules.

Definition at line 63 of file ModuleLoader.php.