ModuleProvider API

The ModuleProvider API allows extension authors to work with the registered modules.

This API is the central point to retrieve modules, since it automatically performs necessary access checks and prepares specific structures, for example for the use in menus.

class TYPO3\CMS\Backend\Module\ModuleProvider

This is the central point to retrieve modules from the ModuleRegistry, while performing the necessary access checks, which ModuleRegistry does not deal with.

isModuleRegistered(string $identifier)

Simple wrapper for the registry, which just checks if a module is registered. Does NOT perform any access checks.

Parameters
  • $identifier (string) -- the identifier

Return type

bool

getModule(string $identifier, TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication $user = NULL, bool $respectWorkspaceRestrictions = true)

Returns a Module for the given identifier. In case a user is given, also access checks are performed.

Parameters
  • $identifier (string) -- the identifier

  • $user (TYPO3\CMS\Core\Authentication\BackendUserAuthentication) -- the user, default: NULL

  • $respectWorkspaceRestrictions (bool) -- the respectWorkspaceRestrictions, default: true

Return type

TYPO3\CMS\Backend\Module\ModuleInterface

getModules(TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication $user = NULL, bool $respectWorkspaceRestrictions = true, bool $grouped = true)

Returns all modules either grouped by main modules or flat.

In case a user is given, also access checks are performed.

Parameters
  • $user (TYPO3\CMS\Core\Authentication\BackendUserAuthentication) -- the user, default: NULL

  • $respectWorkspaceRestrictions (bool) -- the respectWorkspaceRestrictions, default: true

  • $grouped (bool) -- the grouped, default: true

Return type

array

getModuleForMenu(string $identifier, TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication $user, bool $respectWorkspaceRestrictions = true)

Return the requested (main) module if exist and allowed, prepared for menu generation or similar structured output (nested). Takes TSConfig into account. Does not respect "appearance[renderInModuleMenu]".

Parameters
  • $identifier (string) -- the identifier

  • $user (TYPO3\CMS\Core\Authentication\BackendUserAuthentication) -- the user

  • $respectWorkspaceRestrictions (bool) -- the respectWorkspaceRestrictions, default: true

Return type

TYPO3\CMS\Backend\Module\MenuModule

getModulesForModuleMenu(TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication $user, bool $respectWorkspaceRestrictions = true)

Returns all allowed modules for the current user, prepared for module menu generation or similar structured output (nested).

Takes TSConfig and "appearance[renderInModuleMenu]" into account.

Parameters
  • $user (TYPO3\CMS\Core\Authentication\BackendUserAuthentication) -- the user

  • $respectWorkspaceRestrictions (bool) -- the respectWorkspaceRestrictions, default: true

Return type

array

accessGranted(string $identifier, TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication $user, bool $respectWorkspaceRestrictions = true)

Check access of a module for a given user

Parameters
  • $identifier (string) -- the identifier

  • $user (TYPO3\CMS\Core\Authentication\BackendUserAuthentication) -- the user

  • $respectWorkspaceRestrictions (bool) -- the respectWorkspaceRestrictions, default: true

Return type

bool

ModuleInterface

The registered backend modules are stored as objects in a registry. All module objects implement the ModuleInterface. This allows a well-defined OOP-based approach to work with registered models.

The ModuleInterface basically provides getters for the options defined in the module registration and additionally provides methods for relation handling (main modules and sub modules).

interface TYPO3\CMS\Backend\Module\ModuleInterface

An interface representing a TYPO3 Backend module.

getIdentifier()

The internal name of the module, used for referencing in permissions etc

Return type

string

getPath()

Return the main route path

Return type

string

getIconIdentifier()

The icon identifier for the module

Return type

string

getTitle()

The title of the module, used in the menu

Return type

string

getDescription()

A longer description, common for the "About" section with a long explanation

Return type

string

getShortDescription()

A shorter description, used when hovering over a module in the menu as title attribute

Return type

string

isStandalone()

Useful for main modules that are also "clickable" such as the dashboard module

Return type

bool

getComponent()

Returns the view component responsible for rendering the module (iFrame or name of the web component)

Return type

string

getNavigationComponent()

The web component to be rendering the navigation area

Return type

string

getPosition()

The position of the module, such as [top] or [bottom] or [after => anotherModule] or [before => anotherModule]

Return type

array

getAppearance()

Returns a modules appearance options, e.g. used for module menu

Return type

array

getAccess()

Can be user (editor permissions), admin, or systemMaintainer

Return type

string

getWorkspaceAccess()

Can be "*" (= empty) or "live" or "offline"

Return type

string

getParentIdentifier()

The identifier of the parent module during registration

Return type

string

getParentModule()

Get the reference to the next upper menu item

Return type

TYPO3\CMS\Backend\Module\ModuleInterface

hasParentModule()

Can be checked if the module is a "main module"

Return type

bool

hasSubModule(string $identifier)

Checks whether this module has a submodule with the given identifier

Parameters
  • $identifier (string) -- the identifier

Return type

bool

hasSubModules()

Checks if this module has further submodules

Return type

bool

getSubModule(string $identifier)

Return a submodule given by its full identifier

Parameters
  • $identifier (string) -- the identifier

Return type

TYPO3\CMS\Backend\Module\ModuleInterface

getSubModules()

Return all direct descendants of this module

Return type

array

getDefaultRouteOptions()

Returns module related route options - used for the router

Return type

array

getDefaultModuleData()

Get allowed and available module data properties and their default values.

Return type

array

getAliases()

Return a list of identifiers that are aliases to this module

Return type

array