Skip to content

Commit

Permalink
Fixing errors when calling YamlFileLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
stephankellermayr committed Sep 28, 2024
1 parent 2a2bebc commit 36ac5b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Classes/EventListener/IconpackGetExternalPlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function __invoke(BeforeGetExternalPluginsEvent $event): void
) {
$configuration = $event->getConfiguration();
// Get the external plugin configuration from YAML file
$yaml = (new YamlFileLoader())->load(
$yamlFileLoader = GeneralUtility::makeInstance(YamlFileLoader::class);
$yaml = $yamlFileLoader->load(
'EXT:iconpack/Configuration/RTE/IconpackConfig-v11.yaml'
);
$iconpackConfiguration = $yaml['editor']['externalPlugins'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public function __invoke(BeforePrepareConfigurationForEditorEvent $event): void
$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class);
// Auto configure RTE
if ((bool) $extConf->get('iconpack', 'autoConfigRte')) {
$yamlFileLoader = GeneralUtility::makeInstance(YamlFileLoader::class);
// Add configuration from YAML
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '12.0.0', '<')) {
$yaml = (new YamlFileLoader())->load(
$yaml = $yamlFileLoader->load(
'EXT:iconpack/Configuration/RTE/IconpackConfig-v11.yaml'
);
// Get CSS for CKEditor from installed iconpacks
Expand All @@ -52,7 +53,7 @@ public function __invoke(BeforePrepareConfigurationForEditorEvent $event): void
$yaml['editor']['config']['contentsCss'][] = $cssFile;
}
} else {
$yaml = (new YamlFileLoader())->load(
$yaml = $yamlFileLoader->load(
'EXT:iconpack/Configuration/RTE/IconpackConfig-v12.yaml'
);
}
Expand Down
7 changes: 4 additions & 3 deletions Classes/IconpackRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public function registerIconpack(
2100109271
);
}
$configuration = (new YamlFileLoader())->load($configurationFile);
$yamlFileLoader = GeneralUtility::makeInstance(YamlFileLoader::class);
$configuration = $yamlFileLoader->load($configurationFile);
if (!isset($configuration['iconpack'])) {
throw new InvalidArgumentException(
'The iconpack configuration could not be found in YAML file.',
Expand All @@ -81,7 +82,7 @@ public function registerIconpack(
if ($configurationFileMerge && !empty($configurationFileMerge)) {
$sourceFileMerge = GeneralUtility::getFileAbsFileName($configurationFileMerge);
if (file_exists($sourceFileMerge)) {
$configurationMerge = (new YamlFileLoader())->load($configurationFileMerge);
$configurationMerge = $yamlFileLoader->load($configurationFileMerge);
if (isset($configurationMerge['iconpack'])) {
// Merge only main keys!
$configuration['iconpack'] = array_merge(
Expand Down Expand Up @@ -118,7 +119,7 @@ public function registerIconpack(
$sourceFile = GeneralUtility::getFileAbsFileName($conf);
if (file_exists($sourceFile)) {
if ($fileExt === 'yml' || $fileExt === 'yaml') {
$conf = (new YamlFileLoader())->load($sourceFile);
$conf = $yamlFileLoader->load($sourceFile);
} elseif ($fileExt === 'json') {
$jsonData = file_get_contents($sourceFile);
$conf = json_decode($jsonData, true);
Expand Down

0 comments on commit 36ac5b0

Please sign in to comment.