Skip to content

MassAction abstract class refactoring #4380

Description

@ldusan84

Steps to reproduce

  1. Install Magento from develop branch.
  2. Create a class that extends Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction.
  3. Use that mass action from dropdown.

Expected result

  1. No errors.

Actual result

  1. PHP Fatal error: Call to a member function create() on null in /var/www/html/magento2/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php on line 54

There is a hidden dependency in https://github.com/magento/magento2/blob/develop/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php#L54

It is not obvious that the child class requires collectionFactory to be injected so it's not transparent which objects are needed for this class to work.

I tried to create a PR for this, by moving the collection factory to constructor, but the problem is that for example this class:

https://github.com/magento/magento2/blob/develop/app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php

Requires Magento\Sales\Model\ResourceModel\Order\Collection and this one:

https://github.com/magento/magento2/blob/develop/app/code/Magento/Sales/Controller/Adminhtml/Shipment/AbstractShipment/Pdfshipments.php

Requires Magento\Sales\Model\ResourceModel\Order\Shipment\CollectionFactory

These two don't have the same parent class or interface, so it seems that it's not possible to type hint.

Any thoughts?

Metadata

Metadata

Assignees

Labels

Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentimprovement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions