UpdateServiceProvider.php 1.36 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\Core\DependencyInjection\UpdateServiceProvider.
6 7 8 9
 */

namespace Drupal\Core\DependencyInjection;

10 11
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
12 13

/**
14
 * ServiceProvider class for update.php service overrides.
15
 *
16
 * This class is manually added by update.php via $conf['container_service_providers']
17 18 19
 * and required to prevent various services from trying to retrieve data from
 * storages that do not exist yet.
 */
20
class UpdateServiceProvider implements ServiceProviderInterface {
21 22

  /**
23
   * {@inheritdoc}
24
   */
25
  public function register(ContainerBuilder $container) {
26 27 28 29 30 31 32 33 34
    // Disable the Lock service.
    $container
      ->register('lock', 'Drupal\Core\Lock\NullLockBackend');

    // Prevent config from accessing {cache_config}.
    // @see $conf['cache_classes'], update_prepare_d8_bootstrap()
    $container
      ->register('config.storage', 'Drupal\Core\Config\FileStorage')
      ->addArgument(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY));
35 36 37 38 39 40
    $container->register('module_handler', 'Drupal\Core\Extension\UpdateModuleHandler')
      ->addArgument('%container.modules%');
    $container
      ->register("cache_factory", 'Drupal\Core\Cache\MemoryBackendFactory');
    $container
      ->register('router.builder', 'Drupal\Core\Routing\RouteBuilderStatic');
41 42 43
  }

}