Skip to content

Instantly share code, notes, and snippets.

@leymannx
Created August 19, 2016 11:38
Show Gist options
  • Save leymannx/6cdc544354332ba58619f5146a9ae358 to your computer and use it in GitHub Desktop.
Save leymannx/6cdc544354332ba58619f5146a9ae358 to your computer and use it in GitHub Desktop.
Drupal 8 menu get object
<?php
$node = Drupal::request()->attributes->get('node');
?>
@purushotamrai
Copy link

Use \Drupal::routeMatch()->getParameter('node'); instead

@leymannx
Copy link
Author

@purushotamrai – Why? This won't work on node reviews or node revisions. See https://www.drupal.org/project/drupal/issues/3005029#comment-13180175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment