-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Refactor: Fix lack of customizability of the protected variable linkN… #21230
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Breaking class encapsulation is not a good idea. As this class is pretty legacy I believe the recommended way would be to extend it.
Another possible way is to inject such data via constructor but I'm not sure it makes sense to do such refactoring.
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.
@orlangur thanks for looking into this.
I see breaking class encapsulation as a small problem, because we only add a getter, not a setter.
Extending and rewriting the class would not work well with multiple custom modules (in my case the MagePal module needs to put in the link name; another module we use - FireBear Import Export - already rewrites the class)
Constructor injection might work, but as you say the class seems legacy and I am not sure how to do that. Feel free to propose an alternative way.
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.
Another issue with getter is that plugins will be called each time it is called. So, adding such getter is not a proper extension point.
I was suggesting adding a parameter so that links can be specified later via
di.xml
. This wouldn't improve situation a lot actually.Instead of this, please move links manipulation logic into a new 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.
I was just following what is done in the class already -- there is also
public getAttrSetIdToName
which works the same.But I get the argument that it is not a perfect extension point -- but at least it's a lightweight one.
So shall I refactor the whole links manipulation into a new class now? I was just hoping to make the situation a bit better, and am not sure if I am able to invest lots of time here.
What do you think about merging this one and put a refactoring backlog entry for 2.3.x ? I don't think it makes much sense to do such refactoring in 2.2.x ? Would that be possible?
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.
Maybe the larger scale refactoring can be something I could tackle at the MageFest hackathon :-)
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.
@amenk I'll consult with other maintainers in Slack whether such getters addition is something we can live with.
March 5-8th, 2019, not too much time to wait 👍
Yes, I was thinking of this, most part is in
_saveLinks
but maybe there are some others.Sorry, I missed this PR is targeting 2.2. Currently all changes must be delivered to 2.3.x first, then in case of backward-incompatible refactoring of 2.3 we may think of trade-offs.
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.
It's not easy to contribute :-D