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
Sales module MassAction refactoring #9197
Conversation
|
||
/** | ||
* @param Context $context | ||
* @param Filter $filter | ||
* @param CollectionFactory $collectionFactory | ||
* @param OrderManagementInterface $orderManagement |
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 seems the only subclass from \AbstractMassAction using the OrderManagmentInterface is \MassHold where it is injected via constructor. I don't see a need to declare it as param here.
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.
@avoelkl exactly, thanks, will remove those two.
Hi Dusan! |
Hi @avoelkl thank you for the review. Yes, I agree, this is only one step and some refactoring after this should follow. Looking forward to hearing Magento team's opinion. |
Hi @ldusan84, |
Hi @avoelkl Thanks for looking into this. I'll check what's happening on EE and let you know, no worries. |
Hi @avoelkl I have fixed the issues in EE, can you please tell me what would be the best way to submit those changes? |
Hi @ldusan84, |
Hi @avoelkl The thing is that those files that should be changed are EE files that do not exist in the community edition. I don't think that I can commit those here? |
Ah sorry, you're right. My fault. |
We'll give you access to the EE repo, I'll contact you with further details :) |
Hello @ldusan84 Thank you for your everyone collaboration! |
- deprecated Sales AbstractController - added comments in Abstract model to deprecated methods
I think that the MassAction feature in the Sales module is not correctly architectured as it contains hidden dependencies.
Description
If you try to create your own mass action in the sales grid you need to extend the base MassAction class. If you do that you will end up with a fatal error when you use it in admin panel:
"Fatal error: Call to a member function create() on a non-object"
The problem is this:
So the collectionFactory should be injected into constructor but you realize that only after you examine the entire class. We shouldn't do that as we have dependency injection in order to make dependencies visible.
You can find out more about this on my blog post http://dusanlukic.com/magento-2-hidden-dependency-refactoring
I moved the dependency into abstract method making it mandatory for child classes to provide the collection.
This feature needs more refactoring, this would be the first step.
No tests needed as public api remains unchanged.