You are here

function template_preprocess_admin_block_content in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/system.admin.inc \template_preprocess_admin_block_content()
  2. 9 core/modules/system/system.admin.inc \template_preprocess_admin_block_content()

Prepares variables for administrative content block templates.

Default template: admin-block-content.html.twig.

Parameters

$variables: An associative array containing:

  • content: List of administrative menu items. Each menu item contains:

    • url: Path to the admin section.
    • title: Short name of the section.
    • description: Description of the administrative menu item.
    • options: URL options. See \Drupal\Core\Url::fromUri() for details.

File

core/modules/system/system.admin.inc, line 27
Admin page callbacks for the system module.

Code

function template_preprocess_admin_block_content(&$variables) {
  if (!empty($variables['content'])) {
    $variables['compact'] = system_admin_compact_mode();
    foreach ($variables['content'] as $key => $item) {
      $variables['content'][$key]['link'] = Link::fromTextAndUrl($item['title'], $item['url'])
        ->toString();
      if (!$variables['compact'] && isset($item['description'])) {
        $variables['content'][$key]['description'] = [
          '#markup' => $item['description'],
        ];
      }
      else {
        $variables['content'][$key]['description'] = FALSE;
      }
    }
  }
}