LanguageMenuProcessor implements DataProcessorInterface

This menu processor generates a json encoded menu string that will be decoded again and assigned to FLUIDTEMPLATE as variable.

Options: if - TypoScript if condition languages - A list of languages id's (e.g. 0,1,2) to use for the menu creation or 'auto' to load from system or site languages as - The variable to be used within the result

Example TypoScript configuration: 10 = TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor 10 { as = languagenavigation }

Table of Contents

Interfaces

DataProcessorInterface
Interface for data processor classes processing data from ContentObjectRenderer, used e.g. with the FLUIDTEMPLATE content object

Constants

LINK_PLACEHOLDER  = '###LINKPLACEHOLDER###'

Properties

$allowedConfigurationKeys  : array<string|int, mixed>
Allowed configuration keys for menu generation, other keys will throw an exception to prevent configuration errors.
$cObj  : ContentObjectRenderer
The content object renderer
$contentDataProcessor  : ContentDataProcessor
$menuConfig  : array<string|int, mixed>
$menuDefaults  : array<string|int, mixed>
$menuLevelConfig  : array<string|int, mixed>
$menuTargetVariableName  : string
$processorConfiguration  : array<string|int, mixed>
The processor configuration
$removeConfigurationKeysForHmenu  : array<string|int, mixed>
Remove keys from configuration that should not be passed to HMENU to prevent configuration errors

Methods

__construct()  : mixed
Constructor
getFieldAsJson()  : string
Returns the data from the field and language submitted by $conf in JSON format
process()  : array<string|int, mixed>
Process content object data
replacePlaceholderInRenderedMenuItem()  : array<string|int, mixed>
This UserFunc gets the link and the target
setContentObjectRenderer()  : void
This is called from UserContentObject via ContentObjectRenderer->callUserFunction() for nested menu items - those use a USER content object for getFieldAsJson().
buildConfiguration()  : void
Build the menu configuration so it can be treated by HMENU cObject
getConfigurationValue()  : string
Get configuration value from processorConfiguration
getCurrentSite()  : Site
Returns the currently configured "site" if a site is configured (= resolved) in the current request.
getTypoScriptFrontendController()  : TypoScriptFrontendController
jsonEncode()  : string
JSON Encode
prepareConfiguration()  : void
Process languages and filter the configuration
validateAndBuildConfiguration()  : void
Validate and Build the menu configuration so it can be treated by HMENU cObject
validateConfiguration()  : mixed

Constants

protected mixed LINK_PLACEHOLDER = '###LINKPLACEHOLDER###'

Properties

$allowedConfigurationKeys

Allowed configuration keys for menu generation, other keys will throw an exception to prevent configuration errors.

protected array<string|int, mixed> $allowedConfigurationKeys = ['if', 'if.', 'languages', 'languages.', 'as', 'addQueryString', 'addQueryString.']

$menuConfig

protected array<string|int, mixed> $menuConfig = ['special' => 'language', 'addQueryString' => 1, 'wrap' => '[|]']

$menuDefaults

protected array<string|int, mixed> $menuDefaults = ['as' => 'languagemenu']

$menuLevelConfig

protected array<string|int, mixed> $menuLevelConfig = ['doNotLinkIt' => '1', 'wrapItemAndSub' => '{|}, |*| {|}, |*| {|}', 'stdWrap.' => ['cObject' => 'COA', 'cObject.' => ['1' => 'LOAD_REGISTER', '1.' => ['languageId.' => ['cObject' => 'TEXT', 'cObject.' => ['value.' => ['data' => 'register:languages_HMENU'], 'listNum.' => ['stdWrap.' => ['data' => 'register:count_HMENU_MENUOBJ', 'wrap' => '|-1'], 'splitChar' => ',']]]], '10' => 'TEXT', '10.' => ['stdWrap.' => ['data' => 'register:languageId'], 'wrap' => '"languageId":|'], '11' => 'USER', '11.' => ['userFunc' => 'TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor->getFieldAsJson', 'language.' => ['data' => 'register:languageId'], 'field' => 'locale', 'stdWrap.' => ['wrap' => ',"locale":|']], '20' => 'USER', '20.' => ['userFunc' => 'TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor->getFieldAsJson', 'language.' => ['data' => 'register:languageId'], 'field' => 'title', 'stdWrap.' => ['wrap' => ',"title":|']], '21' => 'USER', '21.' => ['userFunc' => 'TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor->getFieldAsJson', 'language.' => ['data' => 'register:languageId'], 'field' => 'navigationTitle', 'stdWrap.' => ['wrap' => ',"navigationTitle":|']], '22' => 'USER', '22.' => ['userFunc' => 'TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor->getFieldAsJson', 'language.' => ['data' => 'register:languageId'], 'field' => 'twoLetterIsoCode', 'stdWrap.' => ['wrap' => ',"twoLetterIsoCode":|']], '23' => 'USER', '23.' => ['userFunc' => 'TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor->getFieldAsJson', 'language.' => ['data' => 'register:languageId'], 'field' => 'hreflang', 'stdWrap.' => ['wrap' => ',"hreflang":|']], '24' => 'USER', '24.' => ['userFunc' => 'TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor->getFieldAsJson', 'language.' => ['data' => 'register:languageId'], 'field' => 'direction', 'stdWrap.' => ['wrap' => ',"direction":|']], '25' => 'USER', '25.' => ['userFunc' => 'TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor->getFieldAsJson', 'language.' => ['data' => 'register:languageId'], 'field' => 'flag', 'stdWrap.' => ['wrap' => ',"flag":|']], '90' => 'TEXT', '90.' => ['value' => self::LINK_PLACEHOLDER, 'wrap' => ',"link":|'], '91' => 'TEXT', '91.' => ['value' => '0', 'wrap' => ',"active":|'], '92' => 'TEXT', '92.' => ['value' => '0', 'wrap' => ',"current":|'], '93' => 'TEXT', '93.' => ['value' => '1', 'wrap' => ',"available":|'], '99' => 'RESTORE_REGISTER']]]

$menuTargetVariableName

protected string $menuTargetVariableName

$processorConfiguration

The processor configuration

protected array<string|int, mixed> $processorConfiguration

$removeConfigurationKeysForHmenu

Remove keys from configuration that should not be passed to HMENU to prevent configuration errors

protected array<string|int, mixed> $removeConfigurationKeysForHmenu = ['languages', 'languages.', 'as']

Methods

__construct()

Constructor

public __construct() : mixed

getFieldAsJson()

Returns the data from the field and language submitted by $conf in JSON format

public getFieldAsJson(string $content, array<string|int, mixed> $conf) : string
Parameters
$content : string

Empty string (no content to process)

$conf : array<string|int, mixed>

TypoScript configuration

Tags
throws
InvalidArgumentException
throws
SiteNotFoundException
Return values
string

JSON encoded data

process()

Process content object data

public process(ContentObjectRenderer $cObj, array<string|int, mixed> $contentObjectConfiguration, array<string|int, mixed> $processorConfiguration, array<string|int, mixed> $processedData) : array<string|int, mixed>
Parameters
$cObj : ContentObjectRenderer

The data of the content element or page

$contentObjectConfiguration : array<string|int, mixed>

The configuration of Content Object

$processorConfiguration : array<string|int, mixed>

The configuration of this processor

$processedData : array<string|int, mixed>

Key/value store of processed data (e.g. to be passed to a Fluid View)

Return values
array<string|int, mixed>

the processed data as key/value store

replacePlaceholderInRenderedMenuItem()

This UserFunc gets the link and the target

public replacePlaceholderInRenderedMenuItem(array<string|int, mixed> $menuItem) : array<string|int, mixed>
Parameters
$menuItem : array<string|int, mixed>
Return values
array<string|int, mixed>

setContentObjectRenderer()

This is called from UserContentObject via ContentObjectRenderer->callUserFunction() for nested menu items - those use a USER content object for getFieldAsJson().

public setContentObjectRenderer(ContentObjectRenderer $cObj) : void
Parameters
$cObj : ContentObjectRenderer

buildConfiguration()

Build the menu configuration so it can be treated by HMENU cObject

protected buildConfiguration() : void

getConfigurationValue()

Get configuration value from processorConfiguration

protected getConfigurationValue(string $key) : string
Parameters
$key : string
Return values
string

getCurrentSite()

Returns the currently configured "site" if a site is configured (= resolved) in the current request.

protected getCurrentSite() : Site
Return values
Site

jsonEncode()

JSON Encode

protected jsonEncode(mixed $value) : string
Parameters
$value : mixed
Return values
string

prepareConfiguration()

Process languages and filter the configuration

protected prepareConfiguration() : void

validateAndBuildConfiguration()

Validate and Build the menu configuration so it can be treated by HMENU cObject

protected validateAndBuildConfiguration() : void

validateConfiguration()

protected validateConfiguration() : mixed
Tags
throws
InvalidArgumentException

        
On this page

Search results