Drupal Node

Drupal Get Node From Route

For Drupal 8 / 9 and 10, finding the node from the route is done with the following code.

$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface) {
 // $node 
}