AbstractXmlParser

abstract class \TYPO3\CMS\Core\Localization\Parser\AbstractXmlParser

Implements
LocalizationParserInterface

Abstract class for XML based parser.

Deprecated

will be removed in TYPO3 v15.0. Switch to Symfony Translation loaders.

Table of Contents

Interfaces

LocalizationParserInterface
Parser interface.

Properties

$languageKey  : string
$sourcePath  : string

Methods

__construct()  : mixed
getParsedData()  : array
Returns parsed representation of XML file.
parseExtensionResource()  : array
New method for parsing xml files, not part of an interface as the plan is to replace the entire API for labels with something different in TYPO3 12
_getParsedData()  : array
Actually doing all the work of parsing an XML file
doParsingFromRoot()  : array
Returns array representation of XML data, starting from a root node.
getLocalizedFileName()  : string
Checks if a localized file is found in labels pack (e.g. a language pack was downloaded in the backend) or if $sameLocation is set, then checks for a file located in "{language}.locallang.xlf" at the same directory
parseXmlFile()  : array
Loads the current XML file before processing.

Properties

Methods

getParsedData()

Returns parsed representation of XML file.

public getParsedData(string $sourcePath, string $languageKey) : array

Parameters

$sourcePath : string

Source file path

$languageKey : string

Language key

Tags

throws
FileNotFoundException

Return values

array

parseExtensionResource()

New method for parsing xml files, not part of an interface as the plan is to replace the entire API for labels with something different in TYPO3 12

public parseExtensionResource(string $sourcePath, string $languageKey, string $fileNamePattern) : array

Parameters

$sourcePath : string
$languageKey : string
$fileNamePattern : string

Return values

array

_getParsedData()

Actually doing all the work of parsing an XML file

protected _getParsedData(string $sourcePath, string $languageKey, string|null $labelsPath) : array

Parameters

$sourcePath : string

Source file path

$languageKey : string

Language key

$labelsPath : string|null

Tags

throws
FileNotFoundException

Return values

array

doParsingFromRoot()

Returns array representation of XML data, starting from a root node.

protected abstract doParsingFromRoot(SimpleXMLElement $root) : array

Parameters

$root : SimpleXMLElement

A root node

Return values

array —

An array representing the parsed XML file

getLocalizedFileName()

Checks if a localized file is found in labels pack (e.g. a language pack was downloaded in the backend) or if $sameLocation is set, then checks for a file located in "{language}.locallang.xlf" at the same directory

protected getLocalizedFileName(string $fileRef, string $language[, bool $sameLocation = false ]) : string

Parameters

$fileRef : string

Absolute file reference to locallang file

$language : string

Language key

$sameLocation : bool = false

If TRUE, then locallang localization file name will be returned with same directory as $fileRef

Return values

string —

Absolute path to the language file

parseXmlFile()

Loads the current XML file before processing.

protected parseXmlFile() : array

Tags

throws
InvalidXmlFileException

Return values

array —

An array representing parsed XML file (structure depends on concrete parser)

On this page