function PreprocessHooks::systemThemesPage

Same name and namespace in other branches
  1. main core/themes/admin/src/Hook/PreprocessHooks.php \Drupal\admin\Hook\PreprocessHooks::systemThemesPage()

Implements hook_preprocess_HOOK() for system_themes_page.

Attributes

#[Hook('preprocess_system_themes_page')]

File

core/themes/admin/src/Hook/PreprocessHooks.php, line 1120

Class

PreprocessHooks
Provides preprocess implementations.

Namespace

Drupal\admin\Hook

Code

public function systemThemesPage(array &$variables) : void {
  if (!empty($variables['theme_groups'])) {
    foreach ($variables['theme_groups'] as &$theme_group) {
      if (!empty($theme_group['themes'])) {
        foreach ($theme_group['themes'] as &$theme_card) {
          // @todo Remove dependency on attributes after
          //   https://www.drupal.org/project/drupal/issues/2511548 has been
          //   resolved.
          if (isset($theme_card['screenshot']['#attributes']) && $theme_card['screenshot']['#attributes'] instanceof Attribute && $theme_card['screenshot']['#attributes']->hasClass('no-screenshot')) {
            unset($theme_card['screenshot']);
          }
          $theme_card['title_id'] = Html::getUniqueId($theme_card['name'] . '-label');
          $description_is_empty = empty((string) $theme_card['description']);
          // Set description_id only if the description is not empty.
          if (!$description_is_empty) {
            $theme_card['description_id'] = Html::getUniqueId($theme_card['name'] . '-description');
          }
          if (!empty($theme_card['operations']) && !empty($theme_card['operations']['#theme']) && $theme_card['operations']['#theme'] === 'links') {
            $theme_card['operations']['#theme'] = 'links__action_links';
          }
        }
      }
    }
  }
}

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