Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. YamlFileLoader.php

function YamlFileLoader::parseNodes

Parses a collection of YAML nodes.

Parameters

array $nodes The YAML nodes:

Return value

array<array|scalar|Constraint>

1 call to YamlFileLoader::parseNodes()
YamlFileLoader::loadClassMetadataFromYaml in vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php

File

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

Class

YamlFileLoader
Loads validation metadata from a YAML file.

Namespace

Symfony\Component\Validator\Mapping\Loader

Code

protected function parseNodes(array $nodes) : array {
    $values = [];
    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);
            }
            if (null !== $options && (!\is_array($options) || array_is_list($options))) {
                $options = [
                    'value' => $options,
                ];
            }
            $values[] = $this->newConstraint(key($childNodes), $options);
        }
        else {
            if (\is_array($childNodes)) {
                $childNodes = $this->parseNodes($childNodes);
            }
            $values[$name] = $childNodes;
        }
    }
    return $values;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal