drupal 9 get nid from node

Solutions on MaxInterview for drupal 9 get nid from node by the best coders in the world

showing results for - "drupal 9 get nid from node"
Matías
17 Aug 2020
1$node = \Drupal::routeMatch()->getParameter('node');
2if ($node instanceof \Drupal\node\NodeInterface) {
3  // You can get nid and anything else you need from the node object.
4  $nid = $node->id();
5}
6