Skip to content
Snippets Groups Projects
Commit ce7d0870 authored by Brian Perry's avatar Brian Perry
Browse files

Issue #3387795: Option to Disable Transitions for Admin Theme

parent 3b503c4f
No related branches found
No related tags found
1 merge request!7Issue #3387795: Option to Disable Transitions for Admin Theme
......@@ -31,7 +31,7 @@ function view_transitions_preprocess_html(&$variables) {
$page_transitions = \Drupal::config('view_transitions.settings')->get('page_transitions');
$animation_type = \Drupal::config('view_transitions.settings')->get('animation_type');
$transition_in_admin = \Drupal::config('view_transitions.settings')->get('transition_in_admin');
$is_admin = \Drupal::service('router.admin_context')->isAdminRoute();
$is_admin = view_transitions_is_admin();
// Don't transition on admin pages unless explicitly enabled
if (!$is_admin || ($is_admin && $transition_in_admin)) {
......@@ -59,3 +59,16 @@ function view_transitions_preprocess_html(&$variables) {
}
}
}
/**
* Determine if the user is at an admin route, or a non-admin route using the toolbar
*/
function view_transitions_is_admin() {
if (\Drupal::service('router.admin_context')->isAdminRoute()) {
return true;
}
if (\Drupal::currentUser()->isAuthenticated() && \Drupal::currentUser()->hasPermission('access toolbar')) {
return true;
}
return false;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment