Skip to content
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

ENH: Prefer dependency injection for GridFieldComponents. #1286

Merged

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Feb 7, 2022

GridFieldComponents packaged with silverstripe/framework will be injectable as of 4.11.0 (see silverstripe/silverstripe-framework#10204)
Explicitly invoking the injector here instead of using create() allows backwards compatibility with framework < 4.11.0 while ensuring dependency injection is still used from 4.11.0 onwards.

If core team would prefer, I can instead use the ::create() static method which was added via the Injectable trait - but that will also require updating the constraint for the framework dependency to ^4.11.

@GuySartorelli GuySartorelli force-pushed the enh/gridfieldcomponents-di branch from 202e855 to 54a619a Compare February 7, 2022 23:38
GridFieldComponents packaged with silverstripe/framework are injectable
as of 4.11.0
Explicitly invoking the injector here instead of using `create()` allows backwards
compatability with framework < 4.11.0 while ensuring dependency
injection is still used from 4.11.0 onwards.
@GuySartorelli GuySartorelli force-pushed the enh/gridfieldcomponents-di branch from 54a619a to 2f9a244 Compare February 8, 2022 00:22
@GuySartorelli
Copy link
Member Author

Once this has been approved I'll go through other repositories and check for GridFieldComponents that are being instantiated with the new keyword but I am waiting to see if this is the preferred way of injecting them before I do so.

Copy link
Contributor

@michalkleiner michalkleiner left a comment

Choose a reason for hiding this comment

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

Both approaches work for me, I'd prefer the ::create one but I'm not sure what's the appetite on forcing ^4.11 onto folks e.g. if someone uses admin in a different version to get newer stuff but wants to stay on older cms/framework. That would force them to alias those dependencies as well.
Will leave for @maxime-rainville or @emteknetnz to make the final call.

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.

4 participants