function InputConfigurator::collectAll
Collects input values for this recipe and its dependencies.
Parameters
\Drupal\Core\Recipe\InputCollectorInterface $collector: The input collector to use.
string[] $processed: The names of the recipes for which input has already been collected. Internal use only, should not be passed in by calling code.
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 135
Class
- InputConfigurator
- Collects and validates input values for a recipe.
Namespace
Drupal\Core\RecipeCode
public function collectAll(InputCollectorInterface $collector, array &$processed = []) : 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.
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, $processed);
}
$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.