You are here

function new_dependency_test_update_8001 in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/new_dependency_test/new_dependency_test.install \new_dependency_test_update_8001()

Enable the new_dependency_test_with_service module.

File

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

Code

function new_dependency_test_update_8001() {
  $services = [
    'new_dependency_test.hard_dependency',
    'new_dependency_test.optional_dependency',
    'new_dependency_test.recursion',
    'new_dependency_test.alias',
    'new_dependency_test.alias_dependency',
    'new_dependency_test.alias2',
    'new_dependency_test.alias_dependency2',
    'new_dependency_test.setter_injection',
  ];

  // Gather the state of the services prior to installing the
  // new_dependency_test_with_service module.
  \Drupal::state()
    ->set('new_dependency_test_update_8001.decorated_service', \Drupal::service('new_dependency_test.another_service')
    ->isDecorated());
  \Drupal::state()
    ->set('new_dependency_test_update_8001.decorated_service_custom_inner', \Drupal::service('new_dependency_test.another_service_two')
    ->isDecorated());
  $map = [];
  foreach ($services as $id) {
    $map[$id] = \Drupal::hasService($id);
  }
  \Drupal::state()
    ->set('new_dependency_test_update_8001.has_before_install', $map);

  // During the update hooks the container is cleaned up to contain only
  // services that have their dependencies met. Core services are available.
  \Drupal::getContainer()
    ->get('module_installer')
    ->install([
    'new_dependency_test_with_service',
  ]);

  // Gather the state of the services after installing the
  // new_dependency_test_with_service module.
  $map = [];
  foreach ($services as $id) {
    $map[$id] = \Drupal::hasService($id);
  }
  \Drupal::state()
    ->set('new_dependency_test_update_8001.has_after_install', $map);
}