Issue #3478771 by phenaproxima, smustgrave, alexpott: InputConfigurator should expose input data definitions

merge-requests/9781/head
Alex Pott 2024-10-07 22:43:08 +01:00
parent 858610568b
commit 2ad947f2f3
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
1 changed files with 16 additions and 2 deletions

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Drupal\Core\Recipe;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\TypedData\TypedDataManagerInterface;
use Symfony\Component\Validator\Exception\ValidationFailedException;
@ -75,6 +76,19 @@ final class InputConfigurator {
}
}
/**
* Returns the typed data definitions for the inputs defined by this recipe.
*
* This does NOT return the data definitions for inputs defined by this
* recipe's dependencies.
*
* @return \Drupal\Core\TypedData\DataDefinitionInterface[]
* The typed data definitions, keyed by input name.
*/
public function getDataDefinitions(): array {
return array_map(fn (TypedDataInterface $data) => $data->getDataDefinition(), $this->data);
}
/**
* Returns the collected input values, keyed by name.
*
@ -98,9 +112,9 @@ final class InputConfigurator {
foreach ($this->dependencies->recipes as $dependency) {
$descriptions = array_merge($descriptions, $dependency->input->describeAll());
}
foreach ($this->data as $key => $data) {
foreach ($this->getDataDefinitions() as $key => $definition) {
$name = $this->prefix . '.' . $key;
$descriptions[$name] = $data->getDataDefinition()->getDescription();
$descriptions[$name] = $definition->getDescription();
}
return $descriptions;
}