summaryrefslogtreecommitdiffstatshomepage
path: root/core/lib/Drupal/Core/Installer/ConfigOverride.php
blob: b343b23c8d8de7faf0be1e246e082b88291c6baa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

namespace Drupal\Core\Installer;

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;

/**
 * Override configuration during the installer.
 */
class ConfigOverride implements ServiceProviderInterface, ConfigFactoryOverrideInterface {

  /**
   * {@inheritdoc}
   */
  public function register(ContainerBuilder $container) {
    // Register this class so that it can override configuration.
    $container
      ->register('core.install_config_override', static::class)
      ->addTag('config.factory.override');
  }

  /**
   * {@inheritdoc}
   */
  public function loadOverrides($names) {
    $overrides = [];
    if (InstallerKernel::installationAttempted() && function_exists('drupal_install_profile_distribution_name')) {
      // Early in the installer the site name is unknown. In this case we need
      // to fallback to the distribution's name.
      $overrides['system.site'] = [
        'name' => drupal_install_profile_distribution_name(),
      ];
    }
    return $overrides;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheSuffix() {
    return 'core.install_config_override';
  }

  /**
   * {@inheritdoc}
   */
  public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata($name) {
    return new CacheableMetadata();
  }

}