drupal 8 get current node code example
Example: drupal 8 get page node
// Get page node.
$node = \Drupal::routeMatch()->getParameter('node');
// Get page entity.
$params = \Drupal::routeMatch()->getParameters()->all();
$entity = reset($params);
// Get page node.
$node = \Drupal::routeMatch()->getParameter('node');
// Get page entity.
$params = \Drupal::routeMatch()->getParameters()->all();
$entity = reset($params);