PHP Класс Neos\Flow\I18n\Cldr\CldrModel

When more than one file path is provided to the constructor, data from all files will be parsed and merged according to the inheritance rules defined in CLDR specification. Aliases are also resolved correctly.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cache Neos\Cache\Frontend\VariableFrontend
$cacheKey string Key used to store / retrieve cached data
$cldrBasePath string An absolute path to the directory where CLDR resides. It is changed only in tests.
$cldrParser CldrParser
$parsedData array
$sourcePaths array Absolute path or path to the files represented by this class' instance.

Открытые методы

Метод Описание
__construct ( array $sourcePaths ) Contructs the model
findNodesWithinPath ( string $path, string $nodeName ) : mixed Returns all nodes with given name found within given path
getAttributeValue ( string $nodeString, string $attributeName ) : mixed Parses the node string and returns a value of attribute for name provided.
getElement ( string $path ) : mixed Returns string value from a path given.
getNodeName ( string $nodeString ) : string Returns node name extracted from node string
getRawArray ( string $path ) : mixed Returns multi-dimensional array representing desired node and it's children.
getRawData ( string $path ) : mixed Returns multi-dimensional array representing desired node and it's children, or a string value if the path points to a leaf.
initializeObject ( ) : void When it's called, CLDR file is parsed or cache is loaded, if available.
injectCache ( Neos\Cache\Frontend\VariableFrontend $cache ) : void Injects the Flow_I18n_Cldr_CldrModelCache cache
injectParser ( CldrParser $parser ) : void

Защищенные методы

Метод Описание
mergeTwoParsedFiles ( mixed $firstParsedData, mixed $secondParsedData ) : array Merges two sets of data from two separate CLDR files into one array.
parseFiles ( array $sourcePaths ) : array Parses given CLDR files using CldrParser and merges parsed data.
resolveAliases ( mixed $data, string $currentPath ) : mixed Resolves any 'alias' nodes in parsed CLDR data.

Описание методов

__construct() публичный Метод

Accepts array of absolute paths to CLDR files. This array can have one element (if model represents one CLDR file) or many elements (if group of CLDR files is going to be represented by this model).
public __construct ( array $sourcePaths )
$sourcePaths array

findNodesWithinPath() публичный Метод

Returns all nodes with given name found within given path
public findNodesWithinPath ( string $path, string $nodeName ) : mixed
$path string A path to search in
$nodeName string A name of the nodes to return
Результат mixed String with desired element, or FALSE on failure

getAttributeValue() публичный статический Метод

An internal representation of CLDR data used by this class is a simple multi dimensional array where keys are nodes' names. If node has attributes, they are all stored as one string (e.g. 'calendar[@type="gregorian"]' or 'calendar[@type="gregorian"][@alt="proposed-x1001"'). This convenient method extracts a value of desired attribute by its name (in example above, in order to get the value 'gregorian', 'type' should be passed as the second parameter to this method). Note: this method does not validate the input!
public static getAttributeValue ( string $nodeString, string $attributeName ) : mixed
$nodeString string A node key to parse
$attributeName string Name of the attribute to find
Результат mixed Value of desired attribute, or FALSE if there is no such attribute

getElement() публичный Метод

Path must point to leaf. Syntax for paths is same as for getRawData.
public getElement ( string $path ) : mixed
$path string A path to the element to get
Результат mixed String with desired element, or FALSE on failure

getNodeName() публичный статический Метод

The internal representation of CLDR uses array keys like: 'calendar[@type="gregorian"]' This method helps to extract the node name from such keys.
public static getNodeName ( string $nodeString ) : string
$nodeString string String with node name and optional attribute(s)
Результат string Name of the node

getRawArray() публичный Метод

This method will return FALSE if the path points to a leaf (i.e. a string, not an array).
См. также: CldrParser
См. также: CldrModel::getRawData()
public getRawArray ( string $path ) : mixed
$path string A path to the node to get
Результат mixed Array of matching data, or FALSE on failure

getRawData() публичный Метод

Syntax for paths is very simple. It's a group of array indices joined with a slash. It tries to emulate XPath query syntax to some extent. Examples: plurals/pluralRules dates/calendars/calendar[@type="gregorian"] Please see the documentation for CldrParser for details about parsed data structure.
См. также: CldrParser
public getRawData ( string $path ) : mixed
$path string A path to the node to get
Результат mixed Array or string of matching data, or FALSE on failure

initializeObject() публичный Метод

When it's called, CLDR file is parsed or cache is loaded, if available.
public initializeObject ( ) : void
Результат void

injectCache() публичный Метод

Injects the Flow_I18n_Cldr_CldrModelCache cache
public injectCache ( Neos\Cache\Frontend\VariableFrontend $cache ) : void
$cache Neos\Cache\Frontend\VariableFrontend
Результат void

injectParser() публичный Метод

public injectParser ( CldrParser $parser ) : void
$parser CldrParser
Результат void

mergeTwoParsedFiles() защищенный Метод

Merging is done with inheritance in mind, as defined in CLDR specification.
protected mergeTwoParsedFiles ( mixed $firstParsedData, mixed $secondParsedData ) : array
$firstParsedData mixed Part of data from first file (either array or string)
$secondParsedData mixed Part of data from second file (either array or string)
Результат array Data merged from two files

parseFiles() защищенный Метод

Merging is done with inheritance in mind, as defined in CLDR specification.
protected parseFiles ( array $sourcePaths ) : array
$sourcePaths array
Результат array Parsed and merged data

resolveAliases() защищенный Метод

CLDR uses 'alias' tag which denotes places where data should be copied from. This tag has 'source' attribute pointing (by relative XPath query) to the source node - it should be copied with all it's children.
protected resolveAliases ( mixed $data, string $currentPath ) : mixed
$data mixed Part of internal array to resolve aliases for (string if leaf, array otherwise)
$currentPath string Path to currently analyzed part of data
Результат mixed Modified (or unchanged) $data

Описание свойств

$cache защищенное свойство

protected VariableFrontend,Neos\Cache\Frontend $cache
Результат Neos\Cache\Frontend\VariableFrontend

$cacheKey защищенное свойство

Key used to store / retrieve cached data
protected string $cacheKey
Результат string

$cldrBasePath защищенное свойство

An absolute path to the directory where CLDR resides. It is changed only in tests.
protected string $cldrBasePath
Результат string

$cldrParser защищенное свойство

protected CldrParser,Neos\Flow\I18n\Cldr $cldrParser
Результат CldrParser

$parsedData защищенное свойство

protected array $parsedData
Результат array

$sourcePaths защищенное свойство

Absolute path or path to the files represented by this class' instance.
protected array $sourcePaths
Результат array