Skip to content

Instantly share code, notes, and snippets.

@aquelito
Last active April 23, 2016 20:56
Show Gist options
  • Save aquelito/d195ca0347fceaa47708845c07906c47 to your computer and use it in GitHub Desktop.
Save aquelito/d195ca0347fceaa47708845c07906c47 to your computer and use it in GitHub Desktop.

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