-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI][DX] Allow exclude
to be an array of patterns
#23956
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
Comments
This is indeed interessting to have something like this: AppBundle\:
resource: '../../src/AppBundle/*'
exclude:
- '../../src/AppBundle/{Entity,Payload,Repository}'
- '../../src/AppBundle/Event/*Event.php' IMHO, it should be a quite easy pick to integrate before the 3.x feature freeze. |
In my opinion this feature is a must-have. In a relatively small app I had to use this and it doesn't look very readable: exclude: '../src/({Entity,Repository,Tests}|SomeDir/SomeFileName)' |
I'd like to work on this feature, is it too late to target 3.4 ? |
👍 this makes sense to me and should indeed target the |
👍 for 3.4 as well |
…netik) This PR was merged into the 4.2-dev branch. Discussion ---------- [DI][DX] Allow exclude to be an array of patterns | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23956 | License | MIT This is basically continuing #24428. In YAML before: ```yaml AppBundle\: resource: '../../src/AppBundle/*' exclude: '../../src/AppBundle/{Entity,Payload,Repository}' ``` in YAML after: ```yaml AppBundle\: resource: '../../src/AppBundle/*' exclude: - '../../src/AppBundle/{Entity,Payload,Repository}' - '../../src/AppBundle/Event/*Event.php' ``` In XML before: ```xml <prototype namespace="App\" resource="../src/*" exclude="../src/{Entity,Migrations,Tests}" /> ``` in XML after: ```xml <prototype namespace="App\" resource="../src/*"> <exclude>../src/{Entity,Migrations,Tests}</exclude> <exclude>../src/Yolo</exclude> </prototype> ``` In PHP before: ```php $di->load(Prototype::class.'\\', '../Prototype') ->autoconfigure() ->exclude('../Prototype/{OtherDir,BadClasses}') ``` In PHP after: ```php $di->load(Prototype::class.'\\', '../Prototype') ->autoconfigure() ->exclude(['../Prototype/OtherDir', '../Prototype/BadClasses']) ``` Everything is backward compatible. Maybe a decision about handling both attribute exclude and element exclude in XML should be taken. Commits ------- 3ae3a03 [DI][DX] Allow exclude to be an array of patterns (taking #24428 over)
What about xml? For example, this one will only ignore 2lvl folder by names, unfortunately, it will try to load as a service any deeper folders in addition to this, cant figure out the synatx for exclude array of rexeps
such are not accepted
|
@BonBonSlick See the PR's description: #27075 |
8687
When was this "glob" syntax ever documented? Since when were parens and pipes ever in any glob implementation? |
It'd be nice if the exclude value could be an array of patterns. I have quite a few classes that I want to exclude from autowiring and a single glob string is getting a bit unwieldy.
Normally, this wouldn't be a problem when all services are private since the DIC removes them if unused, therefore there would be no need to exclude them.
However, in the test environment only, I'm marking all services as public with a compiler pass. (This may be a bad idea.. idk). The reason I'm doing that is that I need to access some services from the container in various functional tests, and I'm getting the warning about accessing private services with ->get(..) to be removed in 4.0.
I thought about tagging those specific services for the compiler pass to recognize and change them to public, but I'm trying to avoid adding DIC config after I was able to delete most of my DIC config since autowiring.
The text was updated successfully, but these errors were encountered: