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
Cannot decorate translation.reader #28843
Comments
I am not sure I understand what you are trying to achieve. Why are you registering the |
@xabbuh I may say why not 😁 ? I'm coming from Silex and love to tweak things. I should be able to decorate/override whatever is in the framework. in this case I'm planning to port a Silex app to sf4 and the language files are split in subfolder by domaine with multiple files within (on for each controller/module). So I want tout keep the files as it (little files are easier tout maintain Imo) |
The App\Translation\Reader\TranslationReader:
decorates: translation.reader |
# Symfony\Component\Translation\Reader\TranslationReader: ~
App\Translation\Reader\TranslationReader:
decorates: translation.reader
# decorates: Symfony\Component\Translation\Reader\TranslationReader
Seams to have the same effect on injection (and it's a good thing imo)
App\Translation\Reader\TranslationReader App\Translation\Reader\TranslationReader
App\Translation\Reader\TranslationReader.inner Symfony\Component\Translation\Reader\TranslationReader
Doctrine\Common\Annotations\Reader alias for "annotations.cached_reader"
Symfony\Component\Translation\Reader\TranslationReader Symfony\Component\Translation\Reader\TranslationReader
Symfony\Component\Translation\Reader\TranslationReaderInterface alias for "App\Translation\Reader\TranslationReader"
annotation_reader alias for "annotations.cached_reader"
annotations.cached_reader Doctrine\Common\Annotations\CachedReader
annotations.reader Doctrine\Common\Annotations\AnnotationReader
doctrine.orm.metadata.annotation_reader alias for "annotations.cached_reader"
translation.reader alias for "App\Translation\Reader\TranslationReader" |
Wait, are we talking about |
Basically I just made a copy of the native reader. So all functions are present. |
If you decorate a service, the method calls configured for that service are not applied to your decorating service. If you need some methods of your class to be called, your service definition needs to reflect that. However, I do not know exactly what you are trying to achieve and maybe service decoration is not the right solution to your problem. But since we use GitHub only to handle bug reports and discuss new features, I need to ask you to use one of the support channels to seek for further help. Since there is nothing to fix in Symfony I am closing here. Thank you for understanding. |
Symfony version(s) affected: 4.1.6
Description
Cannot decorate translation.reader (I want to change the default i18n file loading process)
How to reproduce
copy/adapt
Symfony\Component\Translation\Reader\TranslationReader
toApp\Translation\Reader\TranslationReader
Follow https://symfony.com/doc/current/service_container/service_decoration.html
Modify
services.yaml
Without the alias : the new service is ignored
With the alias :
read()
is trigger but notaddLoder()
Possible Solution
Additional context
$ php bin/console debug:container | grep -i reader
without alias$ php bin/console debug:container | grep -i reader
with aliasThe text was updated successfully, but these errors were encountered: