- 🇩🇪Germany stefan.korn Jossgrund
Hm, still having trouble with 2.x and path aliases (maybe I have overlooked somehting, but I can not get a clean solution with path_aliases. Tried different things, exporting path_alias, removing the 'pid' entry from node export etc.).
Based on #7 (path.alias_storage is gone now) one could use something like this:
$url_aliases = array( 'b64cb122-d96c-467d-b22d-901d8ad3232c' => '/home', '90382fbc-d908-4a27-99e9-2e7017eb2853' => '/api', '75590ebe-b559-4080-9467-c7ff7579cba3' => '/about' ); foreach ($url_aliases as $uuid => $url_alias) { $node = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties([ 'uuid' => $uuid ]); $node = reset($node); if ($node instanceof \Drupal\node\Entity\Node && isset($url_aliases[$uuid])) { \Drupal::entityTypeManager()->getStorage('path_alias')->create( [ 'path' => '/node/' . $node->id(), 'alias' => $url_aliases[$uuid] ] )->save(); }
You can for example put this in a .php file and then execute this via drush scr after the default content has been imported.
Could have also use it in hook_node_insert as per #7, but seems not the cleanest way to run through this every time a node is inserted, though this is kind of a one time task.