function PreprocessHooks::page
Same name and namespace in other branches
- main core/themes/admin/src/Hook/PreprocessHooks.php \Drupal\admin\Hook\PreprocessHooks::page()
Implements hook_preprocess_HOOK() for page.
Attributes
#[Hook('preprocess_page')]
File
-
core/
themes/ admin/ src/ Hook/ PreprocessHooks.php, line 1018
Class
- PreprocessHooks
- Provides preprocess implementations.
Namespace
Drupal\admin\HookCode
public function page(array &$variables) : void {
// Required for allowing sub-theming admin.
$activeThemeName = $this->themeManager
->getActiveTheme()
->getName();
$variables['active_admin_theme'] = $activeThemeName;
$variables['active_navigation'] = $this->moduleHandler
->moduleExists('navigation');
// Expose Route name.
$variables['route_name'] = $this->currentRouteMatch
->getRouteName();
if (preg_match('#entity\\.(?<entity_type_id>.+)\\.canonical#', $variables['route_name'], $matches)) {
$entity = $this->requestStack
->getCurrentRequest()->attributes
->get($matches['entity_type_id']);
if ($entity instanceof EntityInterface && $entity->hasLinkTemplate('edit-form') && $entity->access('update')) {
$variables['entity_title'] = $entity->label();
$variables['entity_edit_url'] = $entity->toUrl('edit-form');
}
}
// Get form actions.
if ($form_actions = Helper::formActions()) {
if ($this->moduleHandler
->moduleExists('navigation')) {
$variables['gin_form_actions'] = '';
}
else {
$variables['gin_form_actions'] = $form_actions;
}
$variables['gin_form_actions_class'] = 'gin-sticky-form-actions--preprocessed';
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.