function UpdateServiceProvider::register

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Update/UpdateServiceProvider.php \Drupal\Core\Update\UpdateServiceProvider::register()
  2. 10 core/lib/Drupal/Core/Update/UpdateServiceProvider.php \Drupal\Core\Update\UpdateServiceProvider::register()
  3. 11.x core/lib/Drupal/Core/Update/UpdateServiceProvider.php \Drupal\Core\Update\UpdateServiceProvider::register()

Overrides ServiceProviderInterface::register

File

core/lib/Drupal/Core/Update/UpdateServiceProvider.php, line 20

Class

UpdateServiceProvider
Customizes the container for running updates.

Namespace

Drupal\Core\Update

Code

public function register(ContainerBuilder $container) {
    $definition = new Definition('Drupal\\Core\\Cache\\NullBackend', [
        'null',
    ]);
    if (method_exists($definition, 'getDeprecation')) {
        $definition->setDeprecated('drupal/core', '8.8.0', 'The "%service_id%\\" service is deprecated. While updating Drupal all caches use \\Drupal\\Core\\Update\\UpdateBackend. See https://www.drupal.org/node/3066407');
    }
    else {
        // @todo Remove when we no longer support Symfony 4 in
        // https://www.drupal.org/project/drupal/issues/3197729
        $definition->setDeprecated(TRUE, 'The "%service_id%\\" service is deprecated. While updating Drupal all caches use \\Drupal\\Core\\Update\\UpdateBackend. See https://www.drupal.org/node/3066407');
    }
    $definition->setPublic(TRUE);
    $container->setDefinition('cache.null', $definition);
    // Decorate the cache factory in order to use
    // \Drupal\Core\Update\UpdateBackend while running updates.
    $container->register('update.cache_factory', UpdateCacheBackendFactory::class)
        ->setDecoratedService('cache_factory')
        ->addArgument(new Reference('update.cache_factory.inner'));
    $container->addCompilerPass(new UpdateCompilerPass(), PassConfig::TYPE_REMOVE, 128);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.