Mercurial > hg > cmmr2012-drupal-site
view vendor/chi-teck/drupal-code-generator/templates/d8/hook/preprocess.twig @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
line wrap: on
line source
/** * Implements hook_preprocess(). */ function {{ machine_name }}_preprocess(&$variables, $hook) { static $hooks; // Add contextual links to the variables, if the user has permission. if (!\Drupal::currentUser()->hasPermission('access contextual links')) { return; } if (!isset($hooks)) { $hooks = theme_get_registry(); } // Determine the primary theme function argument. if (isset($hooks[$hook]['variables'])) { $keys = array_keys($hooks[$hook]['variables']); $key = $keys[0]; } else { $key = $hooks[$hook]['render element']; } if (isset($variables[$key])) { $element = $variables[$key]; } if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) { $variables['title_suffix']['contextual_links'] = contextual_links_view($element); if (!empty($variables['title_suffix']['contextual_links'])) { $variables['attributes']['class'][] = 'contextual-links-region'; } } }