summaryrefslogtreecommitdiffstatshomepage
path: root/core/lib/Drupal/Core/Config/DefaultConfigMode.php
blob: 4e8313e39a682e3a2212245a089e5216484ba173 (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
<?php

declare(strict_types = 1);

namespace Drupal\Core\Config;

/**
 * Provides modes for ConfigInstallerInterface::installDefaultConfig().
 *
 * @see \Drupal\Core\Config\ConfigInstallerInterface::installDefaultConfig()
 */
enum DefaultConfigMode {
  case All;
  case InstallSimple;
  case InstallEntities;
  case Optional;
  case SiteOptional;

  /**
   * Determines if config in /install directory should be created.
   *
   * @return bool
   *   TRUE to create config in /install directory, FALSE if not.
   */
  public function createInstallConfig(): bool {
    return match($this) {
      DefaultConfigMode::All, DefaultConfigMode::InstallSimple, DefaultConfigMode::InstallEntities => TRUE,
      default => FALSE,
    };
  }

  /**
   * Determines if config in /optional directory should be created.
   *
   * @return bool
   *   TRUE to create config in /optional directory, FALSE if not.
   */
  public function createOptionalConfig(): bool {
    return match($this) {
      DefaultConfigMode::All, DefaultConfigMode::Optional => TRUE,
      default => FALSE,
    };
  }

  /**
   * Determines if optional config in other installed modules should be created.
   *
   * @return bool
   *   TRUE to create optional config in other installed modules,
   *   FALSE if not.
   */
  public function createSiteOptionalConfig(): bool {
    return match($this) {
      DefaultConfigMode::All, DefaultConfigMode::SiteOptional => TRUE,
      default => FALSE,
    };
  }

}