Skip to content

Instantly share code, notes, and snippets.

@Kloport
Last active October 21, 2017 13:47
Show Gist options
  • Save Kloport/3db673a5109ba488bd947d6bf1d73963 to your computer and use it in GitHub Desktop.
Save Kloport/3db673a5109ba488bd947d6bf1d73963 to your computer and use it in GitHub Desktop.
function getNodeAliases($langcode = 'en') {
$aliases = [];
$nids = \Drupal::entityQuery('node')
->condition('status', 1) // published
->condition('langcode', $langcode)
->execute();
foreach ($nids as $nid) {
$system_path = '/node/' . $nid;
$path_alias = db_query("SELECT alias FROM {url_alias} WHERE source = '$system_path' AND langcode = '{$langcode}'")->fetchField();
$aliases[] = $path_alias;
}
return $aliases;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment