Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Drupal 8 Snippet

Check if current page is admin page

  if (service('router.admin_context')->isAdminRoute(\Drupal::routeMatch()->getRouteObject())) {
    ...
  }

Get current node type

  $node = \Drupal::routeMatch()->getParameter('node');
  dsm($node->bundle());
  
  if (isset($node) && $node->bundle() == 'article') {
    dsm($node->bundle());
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment