You are here

protected function YamlFileLoader::parseNodes in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php \Symfony\Component\Validator\Mapping\Loader\YamlFileLoader::parseNodes()

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 vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php
Loads the validation metadata from the given YAML class description.

File

vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php, line 84

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;
}