Skip to content

Simplify extractor service configuration #396

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

Closed
wants to merge 4 commits into from

Conversation

rvanlaak
Copy link
Member

@rvanlaak rvanlaak commented Jan 23, 2020

see #395 (comment)

replaces #395

  • import directory over relying on adding extractor service configuration
  • tag all imported services at once based on interface
  • fix deprecated services, use alias instead of extending parent

tags:
- { name: 'php_translation.extractor', type: 'php' }
_defaults:
autowire: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in #372 we should not use autowire.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove it from the defaults 👍

The bundle currently has 4 occurences of using autowiring, so moving it to the level of the service itself seems ok: https://github.com/php-translation/symfony-bundle/search?q=autowire%3A+true&unscoped_q=autowire%3A+true

Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans:
tags:
- { name: 'php_translation.visitor', type: 'php' }
Translation\Extractor\FileExtractor\PHPFileExtractor:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we / should we use the same logic for extractors or does it makes no sense?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What logic are you referring to?

{
$vendorReflection = new \ReflectionClass(FormTypeChoices::class);

return \dirname($vendorReflection->getFileName(), 4);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't it be problematic in some edge cases?

For example, if you use a deployment server to warmup the cache before deploying , as the dirname function use the absolute path, it will be problematic if your project is not on the same location on your deployment server & your production server.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I used FormTypeChoices is because that class already was in code, and thereby already is loadable. If FormTypeChoices would not be supported anymore in the future, more functionality will break. As the extension only runs on compilation of the container, this will keep working.

Related to the dirname function; Wouldn't the composer autoload then also break? The warmup will lead to a compiled container, so the path only is used to locate the classes in a resource. Afterwards, on runtime the composer autoloader will take over again.

@rvanlaak
Copy link
Member Author

replaced by #395

@rvanlaak rvanlaak closed this Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants