ModuleTemplate implements ViewInterface, ResponsableViewInterface uses PageRendererBackendSetupTrait

FinalYes

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

$bodyTag  : string
$docHeaderComponent  : DocHeaderComponent
$extensionConfiguration  : ExtensionConfiguration
$flashMessageQueue  : FlashMessageQueue
$flashMessageService  : FlashMessageService
$formTag  : string
$iconFactory  : IconFactory
$legacyView  : StandaloneView|null
$moduleClass  : string
$moduleId  : string
$moduleName  : string
$moduleProvider  : ModuleProvider
$pageRenderer  : PageRenderer
$request  : ServerRequestInterface
$title  : string
$uiBlock  : bool
$uriBuilder  : UriBuilder
$view  : ViewInterface

Methods

__construct()  : mixed
Init PageRenderer and properties.
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.
getBodyTag()  : string
Returns the current body tag.
getDocHeaderComponent()  : DocHeaderComponent
Get the DocHeader. Can be used in controllers to add custom buttons / menus / ... to the doc header.
getDynamicTabMenu()  : string
Creates a tab menu where the tabs or collapsible are rendered with bootstrap markup
getView()  : StandaloneView
header()  : string
Returns the header-bar in the top of most backend modules Closes section if open.
isUiBlock()  : bool
makeDocHeaderModuleMenu()  : self
Generates a menu in the docheader to access third-level modules
registerModuleMenu()  : self
Generates the Menu for things like Web->Info
render()  : string
Render the module.
renderContent()  : string
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.
setContent()  : self
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.
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.
dispatchNotificationMessages()  : void
Dispatches all messages in a special FlashMessageQueue to the PageRenderer to be rendered as inline notifications
getBackendFavicon()  : string
Retrieves configured favicon for backend with fallback.
getBackendUser()  : BackendUserAuthentication
getLanguageService()  : LanguageService
getNormalizedParams()  : NormalizedParams
getRegisteredStylesheetFolders()  : array<string|int, mixed>
Return an array of all stylesheet directories registered via $GLOBAlS['TBE_STYLES']['skins'].
getUriForFileName()  : string
Returns the uri of a relative reference, resolves the "EXT:" prefix (way of referring to files inside extensions) and checks that the file is inside the project root of the TYPO3 installation
initLegacyView()  : void
loadStylesheets()  : void
Load all registered stylesheets from $GLOBALS['TBE_STYLES'] "API"
prepareRender()  : void
setUpBasicPageRendererForBackend()  : void
Sets mandatory parameters for the PageRenderer.

Properties

$bodyTag

protected string $bodyTag = '<body>'

$legacyView

protected StandaloneView|null $legacyView = null
Tags
deprecated:

Remove together with legacy view handling below in v13.

$moduleClass

protected string $moduleClass = ''

$moduleName

protected string $moduleName = ''

$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, ServerRequestInterface $request) : mixed
Parameters
$pageRenderer : PageRenderer
$iconFactory : IconFactory
$uriBuilder : UriBuilder
$moduleProvider : ModuleProvider
$flashMessageService : FlashMessageService
$extensionConfiguration : ExtensionConfiguration
$view : ViewInterface
$request : ServerRequestInterface

addFlashMessage()

Creates a message object and adds it to the FlashMessageQueue.

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

These messages are automatically rendered when the view is rendered.

Parameters
$messageBody : string
$messageTitle : string = ''
$severity : int|ContextualFeedbackSeverity = ContextualFeedbackSeverity::OK
$storeInSession : bool = true
Tags
todo:

Change $severity to allow ContextualFeedbackSeverity only in v13

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<string|int, mixed> $values) : self
Parameters
$values : array<string|int, mixed>

Array of string keys with mixed-type values.

Return values
self

getBodyTag()

Returns the current body tag.

public getBodyTag() : string
Deprecated

since v12, will be removed in v13.

Return values
string

getDynamicTabMenu()

Creates a tab menu where the tabs or collapsible are rendered with bootstrap markup

public getDynamicTabMenu(array<string|int, mixed> $menuItems, string $domId[, int $defaultTabIndex = 1 ][, bool $collapsible = false ][, bool $wrapContent = true ][, bool $storeLastActiveTab = true ]) : string
Deprecated

since v12, will be removed in v13.

Parameters
$menuItems : array<string|int, mixed>

Tab elements, each element is an array with "label" and "content"

$domId : string

DOM id attribute, will be appended with an iteration number per tab.

$defaultTabIndex : int = 1

Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1 (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing will result in no default tab open.

$collapsible : bool = false

If set, the tabs are rendered as headers instead over each sheet. Effectively this means there is no tab menu, but rather a foldout/fold-in menu.

$wrapContent : bool = true

If set, the content is wrapped in div structure which provides a padding and border style. Set this FALSE to get unstyled content pane with fullsize content area.

$storeLastActiveTab : bool = true

If set, the last open tab is stored in local storage and will be re-open again. If you don't need this feature, e.g. for wizards like import/export you can disable this behaviour.

Return values
string

header()

Returns the header-bar in the top of most backend modules Closes section if open.

public header(string $text[, bool $inlineEdit = true ]) : string
Deprecated

since v12, will be removed in v13.

Parameters
$text : string

The text string for the header

$inlineEdit : bool = true

Whether the header should be editable (e.g. page title)

Return values
string

HTML content

isUiBlock()

public isUiBlock() : bool
Deprecated

since v12, will be removed in v13.

Return values
bool

makeDocHeaderModuleMenu()

Generates a menu in the docheader to access third-level modules

public makeDocHeaderModuleMenu([array<string|int, mixed> $additionalQueryParams = [] ]) : self
Parameters
$additionalQueryParams : array<string|int, mixed> = []
Return values
self

registerModuleMenu()

Generates the Menu for things like Web->Info

public registerModuleMenu(string $moduleMenuIdentifier) : self
Deprecated

since v12, will be removed in v13.

Parameters
$moduleMenuIdentifier : string
Return values
self

render()

Render the module.

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

renderContent()

public renderContent() : string
Deprecated

since v12, will be removed in v13. Remove together with $legacyView property and Templates/Module.html.

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

setContent()

public setContent(string $content) : self
Deprecated

since v12, will be removed in v13.

Parameters
$content : 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
Parameters
$uiBlock : bool
Return values
self

dispatchNotificationMessages()

Dispatches all messages in a special FlashMessageQueue to the PageRenderer to be rendered as inline notifications

protected dispatchNotificationMessages() : void

getBackendFavicon()

Retrieves configured favicon for backend with fallback.

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

getRegisteredStylesheetFolders()

Return an array of all stylesheet directories registered via $GLOBAlS['TBE_STYLES']['skins'].

protected getRegisteredStylesheetFolders() : array<string|int, mixed>
Deprecated

will be removed in TYPO3 v13.0. Use $GLOBALS['TYPO3_CONF_VARS']['BE']['stylesheets'] instead.

Return values
array<string|int, mixed>

getUriForFileName()

Returns the uri of a relative reference, resolves the "EXT:" prefix (way of referring to files inside extensions) and checks that the file is inside the project root of the TYPO3 installation

protected getUriForFileName(ServerRequestInterface $request, string $filename) : string
Parameters
$request : ServerRequestInterface
$filename : string

The input filename/filepath to evaluate

Return values
string

Returns the filename of $filename if valid, otherwise blank string.

initLegacyView()

protected initLegacyView() : void
Deprecated

since v12, will be removed in v13.

loadStylesheets()

Load all registered stylesheets from $GLOBALS['TBE_STYLES'] "API"

protected loadStylesheets(PageRenderer $pageRenderer) : void
Parameters
$pageRenderer : PageRenderer

prepareRender()

protected prepareRender(string $templateFileName) : void
Parameters
$templateFileName : string

        
On this page

Search results