public function ConfigDevelCommands::import in Configuration development 8
Import configuration from module's config directory to active storage.
List which configuration settings you want to export in the module's info file by listing them under 'config_devel', as shown below:
config_devel: install:
- entity.view_display.node.article.default
- entity.view_display.node.article.teaser
- field.instance.node.article.body
optional:
- field.instance.node.article.tags
@command config:devel-import
@usage drush config-devel-import MODULE_NAME Import configuration from the specified module, profile or theme into the active storage, based on .info file. @aliases cdi,cd-im,config-devel-import
Parameters
string $extension Machine name of the module, profile or theme.:
Throws
\Exception Thrown when the passed in extension is not enabled.
File
- src/
Commands/ ConfigDevelCommands.php, line 177
Class
- ConfigDevelCommands
- Drush integration for the Configuration Development module.
Namespace
Drupal\config_devel\CommandsCode
public function import($extension) {
// Determine the type of extension we're dealing with.
$type = $this
->getExtensionType($extension);
if (!$type) {
throw new \Exception("Couldn't import configuration. The '{$extension}' extension is not enabled.");
}
// Get the config
$config = $this
->getExtensionConfig($type, $extension);
if (empty($config)) {
throw new \Exception(sprintf("Couldn't import configuration. There is no config available for %s.", $extension));
}
// Import config
if (isset($config['install'])) {
$this
->importConfig($config['install'], $type, $extension, InstallStorage::CONFIG_INSTALL_DIRECTORY);
}
// Import optional config
if (isset($config['optional'])) {
$this
->importConfig($config['optional'], $type, $extension, InstallStorage::CONFIG_OPTIONAL_DIRECTORY);
}
}