Skip to content

Commit

Permalink
coding standards cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Madison committed Apr 12, 2022
1 parent 0688646 commit 5d668d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 28 deletions.
39 changes: 22 additions & 17 deletions src/Robo/Commands/Recipes/ConfigSplitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace Acquia\Blt\Robo\Commands\Recipes;

use Acquia\Blt\Robo\BltTasks;
use Drupal\Component\Uuid\Php;
use Acquia\Blt\Robo\Exceptions\BltException;
use Acquia\Blt\Robo\Common\YamlMunge;
use Acquia\Blt\Robo\Exceptions\BltException;
use Drupal\Component\Uuid\Php;
use Robo\Contract\VerbosityThresholdInterface;
use Twig\Loader\FilesystemLoader;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;

/**
* Defines commands in the recipes:config:init:splits namespace.
Expand Down Expand Up @@ -66,27 +66,32 @@ public function initialize() {
* @aliases rcis splits
*/
public function generateConfigSplits() {
$this->say("This command will generate configuration and directories for the following environment based splits: Local, CI, Dev, Stage, and Prod.");
$this->say("Creating config splits for the following environments: Local, CI, Dev, Stage, and Prod.");

$default_splits = ['Local', 'CI', 'Dev', 'Stage', 'Prod'];
foreach ($default_splits as $split) {
$this->createSplitConfig($split);
}

// Automatically add config split and config ignore to project configuration.
$core_extensions = YamlMunge::parseFile($this->configSyncDir . '/core.extension.yml');
if (!array_key_exists("config_split", $core_extensions['module'])) {
$core_extensions['module']['config_split'] = 0;
}
if (!array_key_exists("config_filter", $core_extensions['module'])) {
$core_extensions['module']['config_filter'] = 0;
}
try {
ksort($core_extensions['module']);
YamlMunge::writeFile($this->configSyncDir . '/core.extension.yml', $core_extensions);
if (file_exists($this->configSyncDir . '/core.extension.yml')) {
// Automatically enable config split module.
$core_extensions = YamlMunge::parseFile($this->configSyncDir . '/core.extension.yml');
if (!array_key_exists("config_split", $core_extensions['module'])) {
$core_extensions['module']['config_split'] = 0;
}
if (!array_key_exists("config_filter", $core_extensions['module'])) {
$core_extensions['module']['config_filter'] = 0;
}
try {
ksort($core_extensions['module']);
YamlMunge::writeFile($this->configSyncDir . '/core.extension.yml', $core_extensions);
}
catch (\Exception $e) {
throw new BltException("Unable to update core.extension.yml");
}
}
catch (\Exception $e) {
throw new BltException("Unable to update core.extension.yml");
else {
$this->say("No core.extension file found, skipping step to enable config split and config filter modules.");
}
}

Expand Down
12 changes: 1 addition & 11 deletions tests/phpunit/src/ConfgSplitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Acquia\Blt\Tests;

use Acquia\Blt\Robo\Common\YamlMunge;

/**
* Tests Config Split recipe.
*/
Expand All @@ -21,15 +19,6 @@ public function testConfigSplitRecipe() {
}
}

/**
* Tests recipes:config:init:splits to validate core.extension manipulation.
*/
public function testCoreExtension() {
$core_extensions = YamlMunge::parseFile($this->sandboxInstance . '/config/default/core.extension.yml');
$this->assertArrayHasKey("config_filter", $core_extensions['module']);
$this->assertArrayHasKey("config_split", $core_extensions['module']);
}

/**
* Defines the default BLT config splits.
*
Expand All @@ -46,4 +35,5 @@ public function getSplits() {
];
return $splits;
}

}

0 comments on commit 5d668d9

Please sign in to comment.