starter-3.0.x-dev/starter.install
starter.install
<?php
/**
* @file
* Install, update and uninstall functions for the starter installation profile.
*/
use Drupal\user\Entity\User;
/**
* Implements hook_install().
*/
function starter_install() {
// Set front page to "node".
\Drupal::configFactory()->getEditable('system.site')->set('page.front', '/node')->save(TRUE);
// Allow visitor account creation with administrative approval.
$user_settings = \Drupal::configFactory()->getEditable('user.settings');
$user_settings->set('register', 'USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL')->save(TRUE);
// Assign user 1 the "administrator" role.
$user = User::load(1);
$user->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();
// Enable the admin theme.
\Drupal::configFactory()->getEditable('node.settings')->set('use_admin_theme', TRUE)->save(TRUE);
// Change site slogan.
\Drupal::configFactory()->getEditable('system.site')->set('slogan', t('Community plumbing'))->save(TRUE);
}
