-
Notifications
You must be signed in to change notification settings - Fork 93
twig2 compatibility #79
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
Conversation
Nyholm
left a comment
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.
Thank you. I like this change.
What do you think about taking a different approach to avoid using container parameters?
Maybe create config/extractors_twig1.yml and config/extractors_twig2.yml? Then one can do something like this in the TranslationExtension:
if (\Twig_Environment::MAJOR_VERSION === 1) {
$loader->load('extractors_twig1.yml');
} else {
$loader->load('extractors_twig2.yml');
}
Resources/config/extractors.yml
Outdated
| # Twig Visitors: | ||
| php_translation.extractor.twig.visitor.translation_block: | ||
| class: Translation\Extractor\Visitor\Twig\TranslationBlock | ||
| class: %php_translation.extractor.twig.visitor.translation_block.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.
Make sure to quote this parameter
Resources/config/extractors.yml
Outdated
|
|
||
| php_translation.extractor.twig.visitor.translation_filter: | ||
| class: Translation\Extractor\Visitor\Twig\TranslationFilter | ||
| class: %php_translation.extractor.twig.visitor.translation_filter.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.
Make sure to quote this parameter
|
@Nyholm Having two separate files could lead to problems with autocompletion (PHPStorm might lead to the wrong file)? But I am not sure what is better. |
|
PHPStorm does not use Yaml files to autocomplete services. It is using the There is no big deal and we could change this in a patch release later if we want to. |
Nyholm
left a comment
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.
Thank you!
| $container->getDefinition('php_translation.extractor.php.visitor.FormTypeChoices') | ||
| ->addMethodCall('setSymfonyMajorVersion', [Kernel::MAJOR_VERSION]); | ||
|
|
||
| if (\Twig_Environment::MAJOR_VERSION === 1) { |
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.
This variable was introduced in 1.28.0. We should use version_compare and \Twig_Environment::VERSION instead.
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.
@Nyholm done
|
@Nyholm you're right about the autocompletion. Another thing then would be the duplication of all other services in |
|
Yes, I agree.. |
makes use of php-translation/extractor twig2 support