Jun 02, 2020 in
foreach (\Drupal::routeMatch()->getParameters() as $entity) {
  if ($entity instanceof \Drupal\Core\Entity\EntityInterface) {
    // here $entity is your object
  }
}