ModuleProvider

readonly 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.

Table of Contents

Properties

$accessDecisionManager  : AccessDecisionManagerInterface
$moduleRegistry  : ModuleRegistry
$principalFactory  : LegacyUserPrincipalFactory

Methods

__construct()  : mixed
accessGranted()  : bool
Check access of a module for a given user
getFirstAccessibleModule()  : ModuleInterface|null
Returns the first module, accessible for the given user.
getModule()  : ModuleInterface|null
Returns a Module for the given identifier. In case a user is given, also access checks are performed.
getModuleForMenu()  : MenuModule|null
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]".
getModules()  : ModuleInterface[]
Returns all modules either grouped by main modules or flat.
getModulesForModuleMenu()  : MenuModule[]
Returns all allowed modules for the current user, prepared for module menu generation or similar structured output (nested).
getUserModules()  : ModuleInterface[]
Get all modules with access=user, to be selected in the user/group records
isModuleRegistered()  : bool
Simple wrapper for the registry, which just checks if a module is registered. Does NOT perform any access checks.
buildMenuModuleRecursively()  : void
Recursively builds menu module structure, checking access, TSConfig hideModules, and optionally renderInModuleMenu appearance setting at all nesting levels
filterInaccessibleSubModules()  : void
Recursively removes inaccessible submodules from a module at any depth
getModuleMenuState()  : array
hasAccessibleSubModules()  : bool
Check if a module has at least one accessible submodule at any depth

Properties

$accessDecisionManager

protected AccessDecisionManagerInterface $accessDecisionManager

Methods

accessGranted()

Check access of a module for a given user

public accessGranted(string $identifier, BackendUserAuthentication $user[, bool $respectWorkspaceRestrictions = true ]) : bool

Parameters

$identifier : string
$user : BackendUserAuthentication
$respectWorkspaceRestrictions : bool = true

Return values

bool

getModuleForMenu()

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]".

public getModuleForMenu(string $identifier, BackendUserAuthentication $user[, bool $respectWorkspaceRestrictions = true ]) : MenuModule|null

Parameters

$identifier : string
$user : BackendUserAuthentication
$respectWorkspaceRestrictions : bool = true

Return values

MenuModule|null

getModules()

Returns all modules either grouped by main modules or flat.

public getModules([BackendUserAuthentication|null $user = null ][, bool $respectWorkspaceRestrictions = true ][, bool $grouped = true ]) : ModuleInterface[]

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

Parameters

$user : BackendUserAuthentication|null = null
$respectWorkspaceRestrictions : bool = true
$grouped : bool = true

Return values

ModuleInterface[]

getModulesForModuleMenu()

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

public getModulesForModuleMenu(BackendUserAuthentication $user[, bool $respectWorkspaceRestrictions = true ]) : MenuModule[]

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

Parameters

$user : BackendUserAuthentication
$respectWorkspaceRestrictions : bool = true

Return values

MenuModule[]

getUserModules()

Get all modules with access=user, to be selected in the user/group records

public getUserModules() : ModuleInterface[]

Return values

ModuleInterface[]

isModuleRegistered()

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

public isModuleRegistered(string $identifier) : bool

Parameters

$identifier : string

Return values

bool

buildMenuModuleRecursively()

Recursively builds menu module structure, checking access, TSConfig hideModules, and optionally renderInModuleMenu appearance setting at all nesting levels

protected buildMenuModuleRecursively(MenuModule $menuItem, ModuleInterface $module, array $hideModules, BackendUserAuthentication $user, bool $respectWorkspaceRestrictions[, bool $checkRenderInModuleMenu = false ]) : void

Parameters

$menuItem : MenuModule
$module : ModuleInterface
$hideModules : array
$user : BackendUserAuthentication
$respectWorkspaceRestrictions : bool
$checkRenderInModuleMenu : bool = false

hasAccessibleSubModules()

Check if a module has at least one accessible submodule at any depth

protected hasAccessibleSubModules(ModuleInterface $module, array $hideModules, BackendUserAuthentication $user, bool $respectWorkspaceRestrictions[, bool $checkRenderInModuleMenu = false ]) : bool

Parameters

$module : ModuleInterface
$hideModules : array
$user : BackendUserAuthentication
$respectWorkspaceRestrictions : bool
$checkRenderInModuleMenu : bool = false

Return values

bool
On this page