Skip to content

Commit 1afb065

Browse files
committed
[BUGFIX] Ensure only strings are passed to theme settings
1 parent b0a3837 commit 1afb065

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

packages/typo3-docs-theme/src/DependencyInjection/Typo3DocsThemeExtension.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,35 @@ public function load(array $configs, ContainerBuilder $container): void
4848
Typo3DocsThemeSettings::class,
4949
[
5050
'$settings' => [
51-
'typo3_version' => $configs[1]['typo3_version'] ?? 'main',
52-
'edit_on_github' => $configs[1]['edit_on_github'] ?? '',
53-
'edit_on_github_branch' => $configs[1]['edit_on_github_branch'] ?? 'main',
54-
'how_to_edit' => $configs[1]['how_to_edit'] ?? 'https://docs.typo3.org/m/typo3/docs-how-to-document/main/en-us/WritingDocsOfficial/GithubMethod.html',
55-
'interlink_shortcode' => $configs[1]['interlink_shortcode'] ?? '',
56-
'copy_sources' => $configs[1]['copy_sources'] ?? 'true',
57-
'project_home' => $configs[1]['project_home'] ?? '',
58-
'project_contact' => $configs[1]['project_contact'] ?? '',
59-
'project_repository' => $configs[1]['project_repository'] ?? '',
60-
'project_issues' => $configs[1]['project_issues'] ?? '',
51+
'typo3_version' => $this->getConfigValue($configs, 'typo3_version', 'main'),
52+
'edit_on_github' => $this->getConfigValue($configs, 'edit_on_github', ''),
53+
'edit_on_github_branch' => $this->getConfigValue($configs, 'edit_on_github_branch', 'main'),
54+
'how_to_edit' => $this->getConfigValue($configs, 'how_to_edit', 'https://docs.typo3.org/m/typo3/docs-how-to-document/main/en-us/WritingDocsOfficial/GithubMethod.html'),
55+
'interlink_shortcode' => $this->getConfigValue($configs, 'interlink_shortcode', ''),
56+
'copy_sources' => $this->getConfigValue($configs, 'copy_sources', 'true'),
57+
'project_home' => $this->getConfigValue($configs, 'project_home', ''),
58+
'project_contact' => $this->getConfigValue($configs, 'project_contact', ''),
59+
'project_repository' => $this->getConfigValue($configs, 'project_repository', ''),
60+
'project_issues' => $this->getConfigValue($configs, 'project_issues', ''),
6161
],
6262
],
6363
);
6464
$container->setDefinition(Typo3DocsThemeSettings::class, $definition);
6565
}
6666
}
6767

68+
/**
69+
* @param array<int, mixed> $configs
70+
* @return string
71+
*/
72+
private function getConfigValue(array $configs, string $key, string $default): string
73+
{
74+
if (!is_array($configs[1] ?? false) || !isset($configs[1][$key]) || !is_scalar($configs[1][$key])) {
75+
return $default;
76+
}
77+
return strval($configs[1][$key]);
78+
}
79+
6880
public function prepend(ContainerBuilder $container): void
6981
{
7082
$container->prependExtensionConfig('guides', [

0 commit comments

Comments
 (0)