function InputConfigurator::collectAll

Collects input values for this recipe and its dependencies.

Parameters

\Drupal\Core\Recipe\InputCollectorInterface $collector: The input collector to use.

Throws

\Symfony\Component\Validator\Exception\ValidationFailedException Thrown if any of the collected values violate their validation constraints.

File

core/lib/Drupal/Core/Recipe/InputConfigurator.php, line 118

Class

InputConfigurator
Collects and validates input values for a recipe.

Namespace

Drupal\Core\Recipe

Code

public function collectAll(InputCollectorInterface $collector) : void {
    if (is_array($this->values)) {
        throw new \LogicException('Input values cannot be changed once they have been set.');
    }
    // Don't bother collecting values for a recipe we've already seen.
    static $processed = [];
    if (in_array($this->prefix, $processed, TRUE)) {
        return;
    }
    // First, collect values for the recipe's dependencies.
    
    /** @var \Drupal\Core\Recipe\Recipe $dependency */
    foreach ($this->dependencies->recipes as $dependency) {
        $dependency->input
            ->collectAll($collector);
    }
    $this->values = [];
    foreach ($this->data as $key => $data) {
        $definition = $data->getDataDefinition();
        $value = $collector->collectValue($this->prefix . '.' . $key, $definition, $this->getDefaultValue($definition));
        $data->setValue($value, FALSE);
        $violations = $data->validate();
        if (count($violations) > 0) {
            throw new ValidationFailedException($value, $violations);
        }
        $this->values[$key] = $data->getCastedValue();
    }
    $processed[] = $this->prefix;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.