public function getParameters($resolvePlaceholders = true)
{
$this->applyEnvVars();
$parameters = [];
if (!isset($this->blueprintConfig['parameters'])) {
return [];
}
$prefixes = [];
foreach (array_keys($this->getTemplates()) as $key) {
if (!is_int($key)) {
$prefixes[] = $key;
}
}
foreach (array_keys($this->getOptionalTemplates()) as $key) {
if (!is_int($key)) {
$prefixes[] = $key;
}
}
foreach ($this->blueprintConfig['parameters'] as $parameterKey => $parameterValue) {
if (!preg_match('/^[\\*A-Za-z0-9]{1,255}$/', $parameterKey)) {
throw new \Exception("Invalid parameter key '{$parameterKey}'.");
}
if (is_null($parameterValue)) {
throw new \Exception("Parameter {$parameterKey} is null.");
}
if ($resolvePlaceholders) {
$parameterValue = $this->valueResolver->resolvePlaceholders($parameterValue, $this, 'parameter', $parameterKey);
}
if (!is_scalar($parameterValue)) {
throw new \Exception('Invalid type for value');
}
if (strpos($parameterKey, '*') !== false) {
// resolve the '*' when using multiple templates with prefixes
if (empty($prefixes)) {
throw new \Exception("Found placeholder '*' in parameter key but the templates don't use prefixes");
}
foreach ($prefixes as $prefix) {
$parameters[] = ['ParameterKey' => str_replace('*', $prefix, $parameterKey), 'ParameterValue' => $parameterValue];
}
} else {
$parameters[] = ['ParameterKey' => $parameterKey, 'ParameterValue' => $parameterValue];
}
}
return $parameters;
}