Skip to content

Commit

Permalink
Issue #625: Tugboat urls support query parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdavidburns committed Aug 30, 2024
1 parent ca4d38f commit 6ba2c09
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/ScaffoldInstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,36 +407,30 @@ private function installTugboat(string $scaffoldPath): void {

// Filter out unsupported config overrides.
if (!empty($tugboatConfigOverride['php']) && is_array($tugboatConfigOverride['php'])) {
$tugboatConfigOverride['php'] = array_filter($tugboatConfigOverride['php'],
function($key) {
return in_array($key,
['aliases', 'urls', 'visualdiff', 'screenshot']
);
$tugboatConfigOverride['php'] = array_filter($tugboatConfigOverride['php'], function($key) {
return in_array($key, ['aliases', 'urls', 'visualdiff', 'screenshot']);
}, ARRAY_FILTER_USE_KEY);

// Prepare YAML data with custom handling for URLs.
// Prepare YAML data
$yamlData = [];
foreach ($tugboatConfigOverride['php'] as $key => $value) {
if ($key === 'urls' && is_array($value)) {
// Ensure URLs are added without encoding.
$yamlData[$key] = $value;
} else {
$yamlData[$key] = $value;
}
$yamlData[$key] = $value;
}

// Convert the array to a YAML string.
$yamlString = Yaml::dump($yamlData, 2, 2);

// Decode any HTML entities that were encoded
$yamlString = html_entity_decode($yamlString, ENT_QUOTES, 'UTF-8');

// Indent the YAML string for formatting.
$overrideOutput = [];
foreach (explode(PHP_EOL, $yamlString) as $line) {
$overrideOutput[] = str_repeat(' ', 4) . $line;
}

// Assign the formatted YAML string back to the configuration.
$tugboatConfig['overrides']['php'] = rtrim(implode("\n",
$overrideOutput));
$tugboatConfig['overrides']['php'] = rtrim(implode("\n", $overrideOutput));
}

// Add Redis service.
Expand Down

0 comments on commit 6ba2c09

Please sign in to comment.