Add cache tags to quick form help text render array

This commit is contained in:
Paul Weidner 2024-01-29 23:48:30 -08:00 committed by Michael Stenta
parent e23e5923dc
commit 3972ea268f
1 changed files with 9 additions and 3 deletions

View File

@ -23,11 +23,17 @@ function farm_quick_help($route_name, RouteMatchInterface $route_match) {
if (strpos($route_name, 'farm.quick.') === 0) {
$quick_form_id = $route_match->getParameter('id');
if ($route_name == 'farm.quick.' . $quick_form_id) {
/** @var \Drupal\farm_quick\Entity\QuickFormInstanceInterface $quick_form */
$quick_form = \Drupal::service('quick_form.instance_manager')->getInstance($quick_form_id);
$help_text = $quick_form->getHelpText();
if (!empty($help_text)) {
$output .= '<p>' . $help_text . '</p>';
}
$output = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $help_text,
'#cache' => [
'tags' => $quick_form->getCacheTags(),
],
];
}
}