You are here

function module_test_install in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/module_test/module_test.install \module_test_install()
  2. 7 modules/simpletest/tests/module_test.install \module_test_install()
  3. 9 core/modules/system/tests/modules/module_test/module_test.install \module_test_install()

Implements hook_install().

File

core/modules/system/tests/modules/module_test/module_test.install, line 32
Install, update and uninstall functions for the module_test module.

Code

function module_test_install() {
  $schema = module_test_schema()['module_test'];
  Database::getConnection()
    ->insert('module_test')
    ->fields([
    'data' => $schema['fields']['data']['type'],
  ])
    ->execute();
  if (\Drupal::state()
    ->get('module_test_install:rebuild_container')) {

    // Ensure that the container can be rebuilt during hook_install(). Doing
    // this in hook_install() is bad practice but it should not break anything.
    \Drupal::service('kernel')
      ->rebuildContainer();
  }
}