Skip to content

[DI] Enable auto alias compiler pass by default #34884

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

Merged

Conversation

X-Coder264
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature?
Deprecations? no
Tickets Fix #34194
License MIT
Doc PR

I'm sending this PR to trigger a discussion as @nicolas-grekas suggested in #34194

I'm using this quite a lot in one of my applications and I don't see any reasons why it shouldn't be enabled by default.

@X-Coder264 X-Coder264 force-pushed the enable-auto-alias-compiler-pass-by-default branch from b38947a to 4fde517 Compare December 8, 2019 23:12
@ogizanagi ogizanagi added this to the next milestone Dec 9, 2019
@fabpot
Copy link
Member

fabpot commented Feb 5, 2020

Thank you @X-Coder264.

fabpot added a commit that referenced this pull request Feb 5, 2020
…er264)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[DI] Enable auto alias compiler pass by default

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  |
| Deprecations? | no
| Tickets       | Fix #34194
| License       | MIT
| Doc PR        |

I'm sending this PR to trigger a discussion as @nicolas-grekas suggested in #34194

I'm using this quite a lot in one of my applications and I don't see any reasons why it shouldn't be enabled by default.

Commits
-------

4fde517 Enable auto alias compiler pass by default
@fabpot fabpot merged commit 4fde517 into symfony:master Feb 5, 2020
@X-Coder264 X-Coder264 deleted the enable-auto-alias-compiler-pass-by-default branch February 5, 2020 16:43
@TomasVotruba
Copy link
Contributor

I just noticed by accident. What is this feature for? Is there some docs?

@nicolas-grekas
Copy link
Member

@TomasVotruba
Copy link
Contributor

That looks very confusing. What is the usecase?

@X-Coder264
Copy link
Contributor Author

X-Coder264 commented Feb 9, 2020

For example, I work on a highly modular application that is working in different European countries (one instance of the app per country). Almost all features must be switchable (they can be enabled or disabled depending on the requrements - which we solve with Flagception), but a lot of these features also have different requirements for each country - business validation rules, export stuff (what data and in what format must be exported), stuff like fiscalization where each country has its own authority to which you have to register the invoices that you create for your customers when they pay for something on the platform (and each of them has a different API which we must consume) etc.

So all of that stuff which needs to be customized differently because it's country specific has an interface and thanks to this auto-alias feature all I have to do is change the parameter which controls the auto-aliasing in parameters.yaml to point the interface alias to the concrete implementation of that interface for that country.

Fiscalization example:

Domain\Billing\Fiscalization\AuthorityRegistratorInterface:
        tags:
            - { name: auto_alias, format: '%fiscalization_authority_registrator_class%' }

And then in parameters.yaml of the Croatian app I have:

fiscalization_authority_registrator_class: Infrastructure\Billing\Fiscalization\CroatianAuthority\AuthorityRegistrator

while for the Slovenian app it is:

fiscalization_authority_registrator_class: Infrastructure\Billing\Fiscalization\SlovenianAuthority\AuthorityRegistrator

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Feb 9, 2020

Why not separate that via existing *_env.yaml convention? It support also routing and parameters compared services only.

@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Enable AutoAliasServicePass compiler pass by default
6 participants