-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use typo3 core YamlFileLoader #54
base: main
Are you sure you want to change the base?
Conversation
This way imports in sites config yaml files are processed.
GeneralUtility::addInstance( | ||
YamlFileLoader::class, | ||
GeneralUtility::makeInstance( | ||
YamlFileLoader::class, | ||
$this->createMock(Logger::class), | ||
), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brotkrueml This may could be done more elegant..
I got errors when running the phpunit test because of missing argument (Logger) for YamlFileLoader class (is instantiated in ConfigurationFinder.php L148. I was struggeling with the dependency injection of the LoggerAwareInterface for the YamlFileLoader class here and that was the solution i found which satisfied the test cases :)
@tbal Thanks for the PR, will have a look soon. I think, I considered that, but ran into problems, but was long time ago. Maybe TYPO3 v10/v11. |
|
||
private static function getYamlFileLoader(): YamlFileLoader | ||
{ | ||
self::$yamlFileLoader ??= GeneralUtility::makeInstance(YamlFileLoader::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I shy away from using GeneralUtility::makeInstance() at this point: when the ConfigurationFinder is utilized, there is no dependency injection container available. This might work now (haven't tested it), but won't bet on it for future TYPO3 versions. Better would be to instantiate manually:
new YamlFileLoader(new NullLogger());
But: as TYPO3 uses here dependency injection already for the logger, this might cause problems in future versions, when other dependencies might be injected. Then this may result in removing this feature and using the plain Symfony YamlFileLoader again.
Another possibility will be to copy the import functionality over to this extension (or the whole class without the logging).
What do you think? @tbal
As I have concerns about using TYPO3's YamlFileLoader: You can also use environment variables directly for the various configuration options (like auth token and site id). But I assume, you know that? |
Okay, thought about it again: We can use TYPO3's YamlFileLoader. If something changes there (like more classes injected), the functionality can be moved into the extension itself (like currently with the environment variables handling). But I do not want to use I am not sure if we have the correct logging available at compile time, if not, I see two possibilities:
Currently, I am slightly in favour of the custom logger (base on the PSR-3 |
Basically looks like doing it this way again cb4f841 ?! 😄 |
That time ago I was young and unknowing. |
@tbal I implemented a slightly different solution with acc3183. As it works with imports, I get an error when saving the site configuration (TYPO3 v12):
The |
LGTM. Even though it feels a little "unhealthy" using a NullLogger ;)
This error seems to be a security feature :) See: https://github.com/TYPO3/typo3/blob/12.4/typo3/sysext/core/Classes/Configuration/Loader/YamlPlaceholderGuard.php#L89 |
@tbal Finished now the feature. Would be nice if you can test it for your purpose and give feedback. Use the branch use-typo3-yamlfileloader. Will then merge to main and release a new version. Thanks 👍 |
This way imports in sites config yaml files are processed.
Also extra code for parsing and processing of env vars (%env(MY_ENV)%) is removed, while already implemented by YamlFileLoader.
All tests and qa done and succeed for T3 v12 + v13.3.
Background
Usually our config/sites/*/config.yaml import application context dependent configuration:
Contexts (e.g. Production, Staging, Development) can have different values for matomoWidgets* settings (mostly matomoWidgetsUrl and matomoWidgetsIdSite).
The previously used Symfony Yaml Parser didn't processed imports.