roles[] = 'administrator'; $user->save(); // We install some menu links, so we have to rebuild the router, to ensure the // menu links are valid. \Drupal::service('router.builder')->rebuildIfNeeded(); // Populate the default shortcut set. $shortcut = Shortcut::create([ 'shortcut_set' => 'default', 'title' => t('Add content'), 'weight' => -20, 'link' => ['uri' => 'internal:/node/add'], ]); $shortcut->save(); $shortcut = Shortcut::create([ 'shortcut_set' => 'default', 'title' => t('All content'), 'weight' => -19, 'link' => ['uri' => 'internal:/admin/content'], ]); $shortcut->save(); }