ModuleTemplate

final class \TYPO3\CMS\Backend\Template\ModuleTemplate

Implements
ViewInterface, ResponsableViewInterface
Uses
PageRendererBackendSetupTrait

A class taking care of the "outer" HTML of a module, especially the doc header and other related parts.

Table of Contents

Interfaces

ViewInterface
A generic view interface.
ResponsableViewInterface
An optional addition to ViewInterface that allows getting a PSR-7 Response directly.

Properties

$componentFactory  : ComponentFactory
$extensionConfiguration  : ExtensionConfiguration
$flashMessageService  : FlashMessageService
$iconFactory  : IconFactory
$moduleProvider  : ModuleProvider
$pageRenderer  : PageRenderer
$request  : ServerRequestInterface
$uriBuilder  : UriBuilder
$view  : ViewInterface

Methods

__construct()  : mixed
Init PageRenderer and properties.
addButtonToButtonBar()  : self
Shorthand method to add a new button to the button bar
addFlashMessage()  : self
Creates a message object and adds it to the FlashMessageQueue.
assign()  : self
Add a variable to the view data collection.
assignMultiple()  : self
Add multiple variables to the view data collection.
getDocHeaderComponent()  : DocHeaderComponent
Get the DocHeader. Can be used in controllers to add custom buttons / menus / ... to the doc header.
makeDocHeaderModuleMenu()  : self
Generates a module actions dropdown in the docheader button bar.
render()  : string
Render the module.
renderResponse()  : ResponseInterface
Render the module and create an HTML 200 response from it. This is a lazy shortcut so controllers don't need to take care of this in the backend.
setBodyTag()  : self
Set to something like '<body id="foo">' when a special body tag is needed.
setFlashMessageQueue()  : self
ModuleTemplate by default uses queue 'core.template.flashMessages'. Modules may want to maintain an own queue. Use this method to render flash messages of a non-default queue at the default position in module HTML output. Call this method *before* adding single messages with addFlashMessage().
setForm()  : self
A "<form>" tag encapsulating the entire module, including doc-header.
setLayout()  : self
setModuleClass()  : self
Optional 'class="module {moduleClass}"' on first <div> in body.
setModuleId()  : self
Optional 'data-module-id="{moduleId}"' on first <div> in body.
setModuleName()  : self
Optional 'data-module-name="{moduleName}"' on first <div> in body.
setTitle()  : self
Title string of the module: "My module · Edit view"
setUiBlock()  : self
UI block is a spinner shown during browser rendering phase of the module, automatically removed when rendering finished. This is done by default, but the UI block can be turned off when needed for whatever reason.
getBackendFavicon()  : string
Retrieves configured favicon for backend with fallback.
getUriForFileName()  : string
Returns the uri for a system resource
loadStylesheets()  : void
Load all registered stylesheets from $GLOBALS['TYPO3_CONF_VARS']['BE']['stylesheets']
setUpBasicPageRendererForBackend()  : void
Sets mandatory parameters for the PageRenderer.

Properties

$request read-only

protected ServerRequestInterface $request

Methods

__construct()

Init PageRenderer and properties.

public __construct(PageRenderer $pageRenderer, IconFactory $iconFactory, UriBuilder $uriBuilder, ModuleProvider $moduleProvider, FlashMessageService $flashMessageService, ExtensionConfiguration $extensionConfiguration, ViewInterface $view, ComponentFactory $componentFactory, ServerRequestInterface $request) : mixed

Parameters

$pageRenderer : PageRenderer
$iconFactory : IconFactory
$uriBuilder : UriBuilder
$moduleProvider : ModuleProvider
$flashMessageService : FlashMessageService
$extensionConfiguration : ExtensionConfiguration
$view : ViewInterface
$componentFactory : ComponentFactory
$request : ServerRequestInterface

addFlashMessage()

Creates a message object and adds it to the FlashMessageQueue.

public addFlashMessage(string $messageBody[, string $messageTitle = '' ][, ContextualFeedbackSeverity $severity = ContextualFeedbackSeverity::OK ][, bool $storeInSession = true ]) : self

These messages are automatically rendered when the view is rendered.

Parameters

$messageBody : string
$messageTitle : string = ''
$severity : ContextualFeedbackSeverity = ContextualFeedbackSeverity::OK
$storeInSession : bool = true

Return values

self

assign()

Add a variable to the view data collection.

public assign(string $key, mixed $value) : self

Parameters

$key : string
$value : mixed

Return values

self

assignMultiple()

Add multiple variables to the view data collection.

public assignMultiple(array $values) : self

Parameters

$values : array

Array of string keys with mixed-type values.

Return values

self

makeDocHeaderModuleMenu()

Generates a module actions dropdown in the docheader button bar.

public makeDocHeaderModuleMenu([array $additionalQueryParams = [] ]) : self

Creates a dropdown button on the LEFT side (group 0) containing navigation to submodules or module actions. The button label shows the currently active module/action.

Parameters

$additionalQueryParams : array = []

Return values

self

render()

Render the module.

public render([string $templateFileName = '' ]) : string

Parameters

$templateFileName : string = ''

Return values

string

renderResponse()

Render the module and create an HTML 200 response from it. This is a lazy shortcut so controllers don't need to take care of this in the backend.

public renderResponse([string $templateFileName = '' ]) : ResponseInterface

Parameters

$templateFileName : string = ''

Return values

ResponseInterface

setBodyTag()

Set to something like '<body id="foo">' when a special body tag is needed.

public setBodyTag(string $bodyTag) : self

Parameters

$bodyTag : string

Return values

self

setFlashMessageQueue()

ModuleTemplate by default uses queue 'core.template.flashMessages'. Modules may want to maintain an own queue. Use this method to render flash messages of a non-default queue at the default position in module HTML output. Call this method *before* adding single messages with addFlashMessage().

public setFlashMessageQueue(FlashMessageQueue $flashMessageQueue) : self

Parameters

$flashMessageQueue : FlashMessageQueue

Return values

self

setForm()

A "<form>" tag encapsulating the entire module, including doc-header.

public setForm([string $formTag = '' ]) : self

Parameters

$formTag : string = ''

Return values

self

setModuleClass()

Optional 'class="module {moduleClass}"' on first <div> in body.

public setModuleClass(string $moduleClass) : self

Can be helpful styling modules.

Parameters

$moduleClass : string

Return values

self

setModuleId()

Optional 'data-module-id="{moduleId}"' on first <div> in body.

public setModuleId(string $moduleId) : self

Can be helpful in JavaScript.

Parameters

$moduleId : string

Return values

self

setModuleName()

Optional 'data-module-name="{moduleName}"' on first <div> in body.

public setModuleName(string $moduleName) : self

Can be helpful in JavaScript.

Parameters

$moduleName : string

Return values

self

setTitle()

Title string of the module: "My module · Edit view"

public setTitle(string $title[, string $context = '' ]) : self

Parameters

$title : string
$context : string = ''

Return values

self

setUiBlock()

UI block is a spinner shown during browser rendering phase of the module, automatically removed when rendering finished. This is done by default, but the UI block can be turned off when needed for whatever reason.

public setUiBlock(bool $uiBlock) : self

While the UI block is active, the doc header button bar is rendered "inert" as well, so that its buttons stay visible but can not be operated. It is released together with the spinner.

Parameters

$uiBlock : bool

Return values

self

getBackendFavicon()

Retrieves configured favicon for backend with fallback.

protected getBackendFavicon(ExtensionConfiguration $extensionConfiguration, ServerRequestInterface $request) : string

Parameters

$extensionConfiguration : ExtensionConfiguration
$request : ServerRequestInterface

Return values

string

loadStylesheets()

Load all registered stylesheets from $GLOBALS['TYPO3_CONF_VARS']['BE']['stylesheets']

protected loadStylesheets(PageRenderer $pageRenderer) : void

Parameters

$pageRenderer : PageRenderer
On this page