PHP Class 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.
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
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.

Method Details

__construct() public méthode

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() public méthode

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
Résultat mixed String with desired element, or FALSE on failure

getAttributeValue() public static méthode

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
Résultat mixed Value of desired attribute, or FALSE if there is no such attribute

getElement() public méthode

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
Résultat mixed String with desired element, or FALSE on failure

getNodeName() public static méthode

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)
Résultat string Name of the node

getRawArray() public méthode

This method will return FALSE if the path points to a leaf (i.e. a string, not an array).
See also: CldrParser
See also: CldrModel::getRawData()
public getRawArray ( string $path ) : mixed
$path string A path to the node to get
Résultat mixed Array of matching data, or FALSE on failure

getRawData() public méthode

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.
See also: CldrParser
public getRawData ( string $path ) : mixed
$path string A path to the node to get
Résultat mixed Array or string of matching data, or FALSE on failure

initializeObject() public méthode

When it's called, CLDR file is parsed or cache is loaded, if available.
public initializeObject ( ) : void
Résultat void

injectCache() public méthode

Injects the Flow_I18n_Cldr_CldrModelCache cache
public injectCache ( Neos\Cache\Frontend\VariableFrontend $cache ) : void
$cache Neos\Cache\Frontend\VariableFrontend
Résultat void

injectParser() public méthode

public injectParser ( CldrParser $parser ) : void
$parser CldrParser
Résultat void

mergeTwoParsedFiles() protected méthode

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)
Résultat array Data merged from two files

parseFiles() protected méthode

Merging is done with inheritance in mind, as defined in CLDR specification.
protected parseFiles ( array $sourcePaths ) : array
$sourcePaths array
Résultat array Parsed and merged data

resolveAliases() protected méthode

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
Résultat mixed Modified (or unchanged) $data

Property Details

$cache protected_oe property

protected VariableFrontend,Neos\Cache\Frontend $cache
Résultat Neos\Cache\Frontend\VariableFrontend

$cacheKey protected_oe property

Key used to store / retrieve cached data
protected string $cacheKey
Résultat string

$cldrBasePath protected_oe property

An absolute path to the directory where CLDR resides. It is changed only in tests.
protected string $cldrBasePath
Résultat string

$cldrParser protected_oe property

protected CldrParser,Neos\Flow\I18n\Cldr $cldrParser
Résultat CldrParser

$parsedData protected_oe property

protected array $parsedData
Résultat array

$sourcePaths protected_oe property

Absolute path or path to the files represented by this class' instance.
protected array $sourcePaths
Résultat array