xxxxxxxxxx
$path = \Drupal::service('path_alias.manager')->getPathByAlias('/this-is-the-alias');
if(preg_match('/node\/(\d+)/', $path, $matches)) {
$node = \Drupal\node\Entity\Node::load($matches[1]);
}
xxxxxxxxxx
Drupal 8
$alias = \Drupal::service('path.alias_manager')->getAliasByPath('/node/'.$nid);
Drupal 9
$alias = \Drupal::service('path_alias.manager')->getAliasByPath('/node/'.$nid);