Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Fixes #1675: Use cm.core.key everywhere. #1693

Merged
merged 4 commits into from
Jun 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 37 additions & 21 deletions src/Robo/Commands/Setup/ConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,22 @@ public function update() {
public function import() {
$strategy = $this->getConfigValue('cm.strategy');
$cm_core_key = $this->getConfigValue('cm.core.key');
$this->logConfig($this->getConfigValue('cm'), 'cm');

if ($strategy != 'none') {
$this->invokeHook('pre-config-import');

// If using core-only or config-split strategies, first check to see if
// required config is exported.
if (in_array($strategy, ['core-only', 'config-split'])) {
$core_config_file = $this->getConfigValue('docroot') . '/' . $this->getConfigValue("cm.core.dirs.$cm_core_key.path") . '/core.extension.yml';
if (!file_exists($core_config_file)) {
$this->logger->warning("BLT will NOT import configuration, $core_config_file was not found.");
}
// This is not considered a failure.
return 0;
}

$task = $this->taskDrush()
->stopOnFail()
->assume(TRUE)
Expand Down Expand Up @@ -68,18 +80,7 @@ public function import() {
$task->run();

$this->checkFeaturesOverrides();

// Check for configuration overrides.
if (!$this->getConfigValue('cm.allow-overrides')) {
$this->say("Checking for config overrides...");
$config_overrides = $this->taskDrush()
->assume(FALSE)
->drush("cex")
->arg('sync');
if (!$config_overrides->run()->wasSuccessful()) {
throw new BltException("Configuration in the database does not match configuration on disk. You must re-export configuration to capture the changes. This could also indicate a problem with the import process, such as changed field storage for a field with existing content. To permit configuration overrides, set cm.allow-overrides to true in blt/project.yml.");
}
}
$this->checkConfigOverrides($cm_core_key);

$result = $this->invokeHook('post-config-import');

Expand All @@ -94,10 +95,7 @@ public function import() {
* @param string $cm_core_key
*/
protected function importCoreOnly($task, $cm_core_key) {
$core_config_file = $this->getConfigValue('docroot') . '/' . $this->getConfigValue("cm.core.dirs.$cm_core_key.path") . '/core.extension.yml';
if (file_exists($core_config_file)) {
$task->drush("config-import")->arg($cm_core_key);
}
$task->drush("config-import")->arg($cm_core_key);
}

/**
Expand All @@ -107,11 +105,8 @@ protected function importCoreOnly($task, $cm_core_key) {
* @param string $cm_core_key
*/
protected function importConfigSplit($task, $cm_core_key) {
$core_config_file = $this->getConfigValue('docroot') . '/' . $this->getConfigValue("cm.core.dirs.$cm_core_key.path") . '/core.extension.yml';
if (file_exists($core_config_file)) {
$task->drush("pm-enable")->arg('config_split');
$task->drush("config-import")->arg('sync');
}
$task->drush("pm-enable")->arg('config_split');
$task->drush("config-import")->arg($cm_core_key);
}

/**
Expand Down Expand Up @@ -167,4 +162,25 @@ protected function checkFeaturesOverrides() {
}
}

/**
* Checks whether core config is overridden.
*
* @param string $cm_core_key
*
* @throws \Acquia\Blt\Robo\Exceptions\BltException
*/
protected function checkConfigOverrides($cm_core_key) {
// Check for configuration overrides.
if (!$this->getConfigValue('cm.allow-overrides')) {
$this->say("Checking for config overrides...");
$config_overrides = $this->taskDrush()
->assume(FALSE)
->drush("cex")
->arg($cm_core_key);
if (!$config_overrides->run()->wasSuccessful()) {
throw new BltException("Configuration in the database does not match configuration on disk. You must re-export configuration to capture the changes. This could also indicate a problem with the import process, such as changed field storage for a field with existing content. To permit configuration overrides, set cm.allow-overrides to true in blt/project.yml.");
}
}
}

}