You are here

function user_install in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/user/user.install \user_install()
  2. 7 modules/user/user.install \user_install()
  3. 10 core/modules/user/user.install \user_install()

Implements hook_install().

3 calls to user_install()
MigrateUserAdminPassTest::setUp in core/modules/user/tests/src/Kernel/Migrate/MigrateUserAdminPassTest.php
MigrateUserTest::setUp in core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php
UserInstallTest::setUp in core/modules/user/tests/src/Kernel/UserInstallTest.php

File

core/modules/user/user.install, line 73
Install, update and uninstall functions for the user module.

Code

function user_install() {
  $storage = \Drupal::entityTypeManager()
    ->getStorage('user');

  // Insert a row for the anonymous user.
  $storage
    ->create([
    'uid' => 0,
    'status' => 0,
    'name' => '',
  ])
    ->save();

  // We need some placeholders here as name and mail are unique.
  // This will be changed by the settings form in the installer.
  $storage
    ->create([
    'uid' => 1,
    'name' => 'placeholder-for-uid-1',
    'mail' => 'placeholder-for-uid-1',
    'status' => TRUE,
  ])
    ->save();
}