You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Copy file name to clipboardexpand all lines: readme/configuration-management.md
+48
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,54 @@ However, BLT does not create any configuration splits for you. For detailed info
99
99
100
100
If for some reason BLT is not working with Config Split, ensure that you are using Drush version 8.1.10 or higher, Config Split version 8.1.0-beta4 or higher, and that `cm.strategy` is set to `config-split` in `blt/project.yml`.
101
101
102
+
### Using update hooks to importing individual config files
103
+
104
+
BLT runs module update hooks before importing configuration changes. For use cases where it is necessary for a configuration change to be imported before the update hook runs, in your hook, you'll need to import the needed configuration from files first. (An example of this would be adding a new taxonomy vocabulary via config, and populating that vocabulary with terms in an update hook.)
105
+
106
+
Code snippet for importing a taxonomy vocabulary config first before creating terms in that vocabulary:
107
+
108
+
use Drupal\taxonomy\Entity\Term;
109
+
110
+
// Import taxonomy from config sync directory.
111
+
$vid = 'foo_terms'; // foo_terms is the vocabularly id.
This depends on a helper function, which can be added to your custom profile:
127
+
128
+
use Drupal\Core\Config\FileStorage;
129
+
130
+
/**
131
+
* Reads a stored config file from config sync directory.
132
+
*
133
+
* @param string $id
134
+
* The config ID.
135
+
*
136
+
* @return array
137
+
* The config data.
138
+
*/
139
+
function foo_read_config_from_sync($id) {
140
+
// Statically cache FileStorage object.
141
+
static $storage;
142
+
143
+
if (empty($storage)) {
144
+
global $config_directories;
145
+
$storage = new FileStorage($config_directories[CONFIG_SYNC_DIRECTORY]);
146
+
}
147
+
return $storage->read($id);
148
+
}
149
+
102
150
## Features-based workflow
103
151
104
152
Features allows you to bundle related configuration files (such as a content type and its fields) into individual feature modules. Drupal treats features just like normal modules, but Features and its dependencies add some special sauce that allow features to not only provide default configuration (like normal modules), but to also update (track and import) changes to this configuration.
0 commit comments