Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\MessageGroupConfiguration\MessageGroupConfigurationParser Class Reference

Utility class to parse and validate message group configurations. More...

Public Member Functions

 getHopefullyValidConfigurations (string $data, ?callable $callback=null)
 Easy to use function to get valid group configurations from YAML.
 
 getDocumentsFromYaml (string $data)
 Given a Yaml string, returns the non-empty documents as an array.
 
 parseDocuments (array $documents)
 Returns group configurations from YAML documents.
 
 getBaseSchema ()
 
 validate (array $config)
 Validates group configuration against schema.
 

Static Public Member Functions

static mergeTemplate (array $base, array $specific)
 Merges a document template (base) to actual definition (specific)
 

Detailed Description

Utility class to parse and validate message group configurations.

Author
Niklas Laxström @license GPL-2.0-or-later

Definition at line 19 of file MessageGroupConfigurationParser.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\Translate\MessageGroupConfiguration\MessageGroupConfigurationParser::__construct ( )

Definition at line 23 of file MessageGroupConfigurationParser.php.

Member Function Documentation

◆ getBaseSchema()

MediaWiki\Extension\Translate\MessageGroupConfiguration\MessageGroupConfigurationParser::getBaseSchema ( )

Definition at line 115 of file MessageGroupConfigurationParser.php.

◆ getDocumentsFromYaml()

MediaWiki\Extension\Translate\MessageGroupConfiguration\MessageGroupConfigurationParser::getDocumentsFromYaml ( string $data)

Given a Yaml string, returns the non-empty documents as an array.

Returns
string[]

Definition at line 78 of file MessageGroupConfigurationParser.php.

◆ getHopefullyValidConfigurations()

MediaWiki\Extension\Translate\MessageGroupConfiguration\MessageGroupConfigurationParser::getHopefullyValidConfigurations ( string $data,
?callable $callback = null )

Easy to use function to get valid group configurations from YAML.

Those not matching schema will be ignored, if schema validation is enabled.

Parameters
string$dataYaml
callable | null$callbackOptional callback which is called on errors. Parameters are document index, processed configuration and error message.
Returns
array Group configurations indexed by message group id.

Definition at line 41 of file MessageGroupConfigurationParser.php.

◆ mergeTemplate()

static MediaWiki\Extension\Translate\MessageGroupConfiguration\MessageGroupConfigurationParser::mergeTemplate ( array $base,
array $specific )
static

Merges a document template (base) to actual definition (specific)

Definition at line 149 of file MessageGroupConfigurationParser.php.

◆ parseDocuments()

MediaWiki\Extension\Translate\MessageGroupConfiguration\MessageGroupConfigurationParser::parseDocuments ( array $documents)

Returns group configurations from YAML documents.

If there is document containing template, it will be merged with other configurations.

Returns
array[][] Unvalidated group configurations

Definition at line 88 of file MessageGroupConfigurationParser.php.

◆ validate()

MediaWiki\Extension\Translate\MessageGroupConfiguration\MessageGroupConfigurationParser::validate ( array $config)

Validates group configuration against schema.

Exceptions
ExceptionIf configuration is not valid.

Definition at line 123 of file MessageGroupConfigurationParser.php.


The documentation for this class was generated from the following file: