class MediaThemeHooks

Hook implementations for media.

Hierarchy

Expanded class hierarchy of MediaThemeHooks

File

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

Namespace

Drupal\media\Hook
View source
class MediaThemeHooks {
  
  /**
   * Implements hook_preprocess_HOOK() for media reference widgets.
   */
  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;
      }
    }
  }

}

Members

Title Sort descending Modifiers Object type Summary
MediaThemeHooks::preprocessMediaReferenceHelp public function Implements hook_preprocess_HOOK() for media reference widgets.

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