function PreprocessHooks::adminBlockContent

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

Implements hook_preprocess_HOOK() for admin_block.

Attributes

#[Hook('preprocess_admin_block_content')]

File

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

Class

PreprocessHooks
Provides preprocess implementations.

Namespace

Drupal\admin\Hook

Code

public function adminBlockContent(array &$variables) : void {
  foreach ($variables['content'] as &$item) {
    $link_attributes = $item['url']->getOption('attributes') ?: [];
    $link_attributes['class'][] = 'admin-item__link';
    $item['url']->setOption('attributes', $link_attributes);
    $item['link'] = Link::fromTextAndUrl($item['title'], $item['url']);
    if (empty($item['description']) || empty($item['description']['#markup'])) {
      unset($item['description']);
    }
  }
}

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