function MediaThemeHooks::preprocessMediaReferenceHelp

Implements hook_preprocess_HOOK() for media reference widgets.

Attributes

#[Hook('preprocess_media_reference_help')]

File

core/modules/media/src/Hook/MediaThemeHooks.php, line 18

Class

MediaThemeHooks
Hook implementations for media.

Namespace

Drupal\media\Hook

Code

public function preprocessMediaReferenceHelp(&$variables) : void {
  // Most of these attribute checks are copied from
  // \Drupal\Core\Form\FormPreprocess::preprocessFieldset(). Our template
  // extends field-multiple-value-form.html.twig to provide our help text, but
  // also groups the information within a semantic fieldset with a legend. So,
  // we incorporate parity for both.
  $element = $variables['element'];
  Element::setAttributes($element, [
    'id',
  ]);
  RenderElementBase::setAttributes($element);
  $variables['attributes'] = $element['#attributes'] ?? [];
  $variables['legend_attributes'] = new Attribute();
  $variables['header_attributes'] = new Attribute();
  $variables['description']['attributes'] = new Attribute();
  $variables['legend_span_attributes'] = new Attribute();
  if (!empty($element['#media_help'])) {
    foreach ($element['#media_help'] as $key => $text) {
      $variables[substr($key, 1)] = $text;
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.