‪TYPO3CMS  ‪main
TYPO3\CMS\Core\TypoScript\TypoScriptService Class Reference

Public Member Functions

array< string|int, convertTypoScriptArrayToPlainArray(array $typoScriptArray):array { foreach( $typoScriptArray as $key=> $value) { if(str_ends_with((string) $key, '.')) { $keyWithoutDot=substr((string) $key, 0, -1);$typoScriptNodeValue=$typoScriptArray[ $keyWithoutDot] ?? null;if(is_array( $value)) { $typoScriptArray[ $keyWithoutDot]=$this-> convertTypoScriptArrayToPlainArray ($value)
 
array convertPlainArrayToTypoScriptArray (array $plainArray)
 
array explodeConfigurationForOptionSplit (array $originalConfiguration, int $splitCount)
 

Public Attributes

 else
 
return $typoScriptArray
 

Detailed Description

Helper class to manage and convert TypoScript into differently shaped arrays. Also contains the functionality in TypoScript called "optionSplit".

Definition at line 26 of file TypoScriptService.php.

Member Function Documentation

◆ convertPlainArrayToTypoScriptArray()

array TYPO3\CMS\Core\TypoScript\TypoScriptService::convertPlainArrayToTypoScriptArray ( array  $plainArray)

Returns an array with Typoscript the old way (with dot).

Extbase converts the "classical" TypoScript (with trailing dot) to a format without trailing dot, to be more future-proof and not to have any conflicts with Fluid object accessor syntax. However, if you want to call legacy TypoScript objects, you somehow need the "old" syntax (because this is what TYPO3 is used to). With this method, you can convert the extbase TypoScript to classical TYPO3 TypoScript which is understood by the rest of TYPO3.

Parameters
array$plainArray‪A TypoScript Array with Extbase Syntax (without dot but with _typoScriptNodeValue)
Returns
‪array Array with TypoScript as usual (with dot)

Avoid using this method. This has been invented for Extbase, which decided to move TypoScript arrays around in just another different way.

Todo:
‪: Usages should be removed mid-term to work on the TypoScript object tree directly.

Definition at line 74 of file TypoScriptService.php.

References TYPO3\CMS\Core\TypoScript\TypoScriptService\$typoScriptArray.

◆ convertTypoScriptArrayToPlainArray()

array<string|int, convertTypoScriptArrayToPlainArray(array $typoScriptArray): array { foreach ($typoScriptArray as $key => $value) { if (str_ends_with((string)$key, '.')) { $keyWithoutDot = substr((string)$key, 0, -1); $typoScriptNodeValue = $typoScriptArray[$keyWithoutDot] ?? null; if (is_array($value)) { $typoScriptArray[$keyWithoutDot] = $this-> TYPO3\CMS\Core\TypoScript\TypoScriptService::convertTypoScriptArrayToPlainArray (   $value)

Removes all trailing dots recursively from TS settings array

Extbase converts the "classical" TypoScript (with trailing dot) to a format without trailing dot, to be more future-proof and not to have any conflicts with Fluid object accessor syntax.

Parameters
array<string|int,mixed>‪$typoScriptArray for example ‘['foo’ => 'TEXT', 'foo.' => ['bar' => 'baz']] @return array<string|int, mixed> for example['foo' => ['_typoScriptNodeValue' => 'TEXT', 'bar' => 'baz']]`

Avoid using this method. This has been invented for Extbase, which decided to move TypoScript arrays around in just another different way.

Todo:
‪: Usages should be removed mid-term to work on the TypoScript object tree directly.

◆ explodeConfigurationForOptionSplit()

array TYPO3\CMS\Core\TypoScript\TypoScriptService::explodeConfigurationForOptionSplit ( array  $originalConfiguration,
int  $splitCount 
)

Implementation of the "optionSplit" feature in TypoScript (used eg. for MENU objects) What it does is to split the incoming TypoScript array so that the values are exploded by certain strings ("||" and "|*|") and each part distributed into individual TypoScript arrays with a similar structure, but individualized values. The concept is known as "optionSplit" and is rather advanced to handle but quite powerful, in particular for creating menus in TYPO3.

Parameters
array$originalConfiguration‪A TypoScript array
int$splitCount‪The number of items for which to generate individual TypoScript arrays
Returns
‪array The individualized TypoScript array.
Todo:
‪: This method is a sign of bad abstraction. It should be modelled differently and located elsewhere.

Definition at line 104 of file TypoScriptService.php.

Member Data Documentation

◆ $typoScriptArray

return TYPO3\CMS\Core\TypoScript\TypoScriptService::$typoScriptArray

◆ else

TYPO3\CMS\Core\TypoScript\TypoScriptService::else
Initial value:
{
‪$typoScriptArray[$keyWithoutDot] = null

Definition at line 52 of file TypoScriptService.php.

‪TYPO3\CMS\Core\TypoScript\TypoScriptService\$typoScriptArray
‪return $typoScriptArray
Definition: TypoScriptService.php:57