From 2ad947f2f3a4e16ae6080b2a8062f88f1568a782 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 7 Oct 2024 22:43:08 +0100 Subject: [PATCH] Issue #3478771 by phenaproxima, smustgrave, alexpott: InputConfigurator should expose input data definitions --- .../Drupal/Core/Recipe/InputConfigurator.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/lib/Drupal/Core/Recipe/InputConfigurator.php b/core/lib/Drupal/Core/Recipe/InputConfigurator.php index d090daaa6c4..9dbc977f84f 100644 --- a/core/lib/Drupal/Core/Recipe/InputConfigurator.php +++ b/core/lib/Drupal/Core/Recipe/InputConfigurator.php @@ -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; }