You are here

public static function ArrayConverter::expandToTree in Plug 7

Converts linear messages array to tree-like array. For example this rray('foo.bar' => 'value') will be converted to array('foo' => array('bar' => 'value')).

Parameters

array $messages Linear messages array:

Return value

array Tree-like messages array

2 calls to ArrayConverter::expandToTree()
ArrayConverterTest::testDump in lib/Symfony/translation/Tests/Util/ArrayConverterTest.php
@dataProvider messsagesData
YamlFileDumper::formatCatalogue in lib/Symfony/translation/Dumper/YamlFileDumper.php
Transforms a domain of a message catalogue to its string representation.

File

lib/Symfony/translation/Util/ArrayConverter.php, line 36

Class

ArrayConverter
ArrayConverter generates tree like structure from a message catalogue. e.g. this 'foo.bar1' => 'test1', 'foo.bar2' => 'test2' converts to follows: foo: bar1: test1 bar2: test2.

Namespace

Symfony\Component\Translation\Util

Code

public static function expandToTree(array $messages) {
  $tree = array();
  foreach ($messages as $id => $value) {
    $referenceToElement =& self::getElementByPath($tree, explode('.', $id));
    $referenceToElement = $value;
    unset($referenceToElement);
  }
  return $tree;
}