From 7bbceff8c4d7a4be67d3c9ee39c86952fab6b50b Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 7 Oct 2024 22:43:08 +0100
Subject: [PATCH] Issue #3478771 by phenaproxima, smustgrave, alexpott:
 InputConfigurator should expose input data definitions

(cherry picked from commit 2ad947f2f3a4e16ae6080b2a8062f88f1568a782)
---
 .../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 d090daaa6c4c..9dbc977f84ff 100644
--- a/core/lib/Drupal/Core/Recipe/InputConfigurator.php
+++ b/core/lib/Drupal/Core/Recipe/InputConfigurator.php
@@ -5,6 +5,7 @@
 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 @@ public function __construct(
     }
   }
 
+  /**
+   * 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 @@ public function describeAll(): array {
     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;
   }
-- 
GitLab