You are here

protected function YamlFileLoader::parseNodes in Plug 7

Parses a collection of YAML nodes.

Parameters

array $nodes The YAML nodes:

Return value

array An array of values or Constraint instances

1 call to YamlFileLoader::parseNodes()
YamlFileLoader::loadClassMetadataFromYaml in lib/Symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php
Loads the validation metadata from the given YAML class description.

File

lib/Symfony/validator/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php, line 83

Class

YamlFileLoader
Loads validation metadata from a YAML file.

Namespace

Symfony\Component\Validator\Mapping\Loader

Code

protected function parseNodes(array $nodes) {
  $values = array();
  foreach ($nodes as $name => $childNodes) {
    if (is_numeric($name) && is_array($childNodes) && 1 === count($childNodes)) {
      $options = current($childNodes);
      if (is_array($options)) {
        $options = $this
          ->parseNodes($options);
      }
      $values[] = $this
        ->newConstraint(key($childNodes), $options);
    }
    else {
      if (is_array($childNodes)) {
        $childNodes = $this
          ->parseNodes($childNodes);
      }
      $values[$name] = $childNodes;
    }
  }
  return $values;
}