summaryrefslogtreecommitdiffstatshomepage
path: root/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php
blob: c4118dd36c42f7987b0426f589edbdedaf239620 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php

namespace Drupal\Core\Config;

/**
 * Interface for classes that install config.
 */
interface ConfigInstallerInterface {

  /**
   * Installs the default configuration of a given extension.
   *
   * When an extension is installed, it searches all the default configuration
   * directories for all other extensions to locate any configuration with its
   * name prefix. For example, the Node module provides the frontpage view as a
   * default configuration file:
   * core/modules/node/config/optional/views.view.frontpage.yml
   * When the Views module is installed after the Node module is already
   * enabled, the frontpage view will be installed.
   *
   * Additionally, the default configuration directory for the extension being
   * installed is searched to discover if it contains default configuration
   * that is owned by other enabled extensions. So, the frontpage view will also
   * be installed when the Node module is installed after Views.
   *
   * @param string $type
   *   The extension type; e.g., 'module' or 'theme'.
   * @param string $name
   *   The name of the module or theme to install default configuration for.
   * @param \Drupal\Core\Config\DefaultConfigMode $mode
   *   The default value DefaultConfigMode::All means create install, optional
   *   and site optional configuration. The other modes create a single type
   *   config.
   *
   * @see \Drupal\Core\Config\ExtensionInstallStorage
   */
  public function installDefaultConfig($type, $name, DefaultConfigMode $mode = DefaultConfigMode::All);

  /**
   * Installs optional configuration.
   *
   * Optional configuration is only installed if:
   * - the configuration does not exist already.
   * - it's a configuration entity.
   * - its dependencies can be met.
   *
   * @param \Drupal\Core\Config\StorageInterface|null $storage
   *   (optional) The configuration storage to search for optional
   *   configuration. If not provided, all enabled extension's optional
   *   configuration directories including the install profile's will be
   *   searched.
   * @param array $dependency
   *   (optional) If set, ensures that the configuration being installed has
   *   this dependency. The format is dependency type as the key ('module',
   *   'theme', or 'config') and the dependency name as the value
   *   ('node', 'olivero', 'views.view.frontpage').
   */
  public function installOptionalConfig(?StorageInterface $storage = NULL, $dependency = []);

  /**
   * Installs all default configuration in the specified collection.
   *
   * The function is useful if the site needs to respond to an event that has
   * just created another collection and we need to check all the installed
   * extensions for any matching configuration. For example, if a language has
   * just been created.
   *
   * @param string $collection
   *   The configuration collection.
   */
  public function installCollectionDefaultConfig($collection);

  /**
   * Sets the configuration storage that provides the default configuration.
   *
   * @param \Drupal\Core\Config\StorageInterface $storage
   *   The storage.
   *
   * @return $this
   */
  public function setSourceStorage(StorageInterface $storage);

  /**
   * Gets the configuration storage that provides the default configuration.
   *
   * @return \Drupal\Core\Config\StorageInterface|null
   *   The configuration storage that provides the default configuration.
   *   Returns null if the source storage has not been set.
   */
  public function getSourceStorage();

  /**
   * Sets the status of the isSyncing flag.
   *
   * @param bool $status
   *   The status of the sync flag.
   *
   * @return $this
   */
  public function setSyncing($status);

  /**
   * Gets the syncing state.
   *
   * @return bool
   *   Returns TRUE is syncing flag set.
   */
  public function isSyncing();

  /**
   * Checks the configuration that will be installed for an extension.
   *
   * @param string $type
   *   Type of extension to install.
   * @param string|array $name
   *   Name or names of extensions to install.
   *
   * @throws \Drupal\Core\Config\UnmetDependenciesException
   * @throws \Drupal\Core\Config\PreExistingConfigException
   */
  public function checkConfigurationToInstall($type, $name);

}