Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drupal 8 menu get object
<?php
$node = Drupal::request()->attributes->get('node');
?>
@ccx105

This comment has been minimized.

Copy link

commented Dec 5, 2017

Awesome thank you so much for this!

@david-services

This comment has been minimized.

Copy link

commented Aug 23, 2018

Usefull, TX

@purushotamrai

This comment has been minimized.

Copy link

commented Jul 9, 2019

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

@leymannx

This comment has been minimized.

Copy link
Owner Author

commented Jul 12, 2019

@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
You can’t perform that action at this time.