Skip to content

Use constructor property promotion in module Shipping #37217

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

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions app/code/Magento/Shipping/Block/Adminhtml/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,34 @@
*/
namespace Magento\Shipping\Block\Adminhtml;

use Magento\Backend\Block\Widget\Context as WidgetContext;
use Magento\Backend\Block\Widget\Form\Container as FormContainer;
use Magento\Framework\Registry;
use Magento\Sales\Model\Order\Shipment as OrderShipment;

/**
* Adminhtml shipment create
*
* @api
* @since 100.0.2
*/
class Create extends \Magento\Backend\Block\Widget\Form\Container
class Create extends FormContainer
{
/**
* Core registry
*
* @var \Magento\Framework\Registry
* @var Registry
*/
protected $_coreRegistry = null;
Copy link
Member

Choose a reason for hiding this comment

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

Why not promote this property?


/**
* @param \Magento\Backend\Block\Widget\Context $context
* @param \Magento\Framework\Registry $registry
* @param WidgetContext $context
* @param Registry $registry
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
\Magento\Framework\Registry $registry,
WidgetContext $context,
Registry $registry,
array $data = []
) {
$this->_coreRegistry = $registry;
Expand All @@ -51,7 +56,7 @@ protected function _construct()
/**
* Retrieve shipment model instance
*
* @return \Magento\Sales\Model\Order\Shipment
* @return OrderShipment
*/
public function getShipment()
{
Expand Down
31 changes: 19 additions & 12 deletions app/code/Magento/Shipping/Block/Adminhtml/Create/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
*/
namespace Magento\Shipping\Block\Adminhtml\Create;

use Magento\Backend\Block\Template\Context as TemplateContext;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Registry;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Sales\Block\Adminhtml\Order\AbstractOrder;
use Magento\Sales\Helper\Admin;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Shipment as OrderShipment;
use Magento\Tax\Helper\Data as TaxHelper;

/**
Expand All @@ -14,19 +21,19 @@
* @api
* @since 100.0.2
*/
class Form extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder
class Form extends AbstractOrder
{
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Sales\Helper\Admin $adminHelper
* @param TemplateContext $context
* @param Registry $registry
* @param Admin $adminHelper
* @param array $data
* @param TaxHelper|null $taxHelper
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Sales\Helper\Admin $adminHelper,
TemplateContext $context,
Registry $registry,
Admin $adminHelper,
array $data = [],
?TaxHelper $taxHelper = null
) {
Expand All @@ -37,7 +44,7 @@ public function __construct(
/**
* Retrieve invoice order
*
* @return \Magento\Sales\Model\Order
* @return Order
*/
public function getOrder()
{
Expand All @@ -47,7 +54,7 @@ public function getOrder()
/**
* Retrieve source
*
* @return \Magento\Sales\Model\Order\Shipment
* @return OrderShipment
*/
public function getSource()
{
Expand All @@ -57,7 +64,7 @@ public function getSource()
/**
* Retrieve shipment model instance
*
* @return \Magento\Sales\Model\Order\Shipment
* @return OrderShipment
*/
public function getShipment()
{
Expand All @@ -67,11 +74,11 @@ public function getShipment()
/**
* Prepare layout.
*
* @return \Magento\Framework\View\Element\AbstractBlock
* @return AbstractBlock
*/
protected function _prepareLayout()
{
$this->addChild('items', \Magento\Shipping\Block\Adminhtml\Create\Items::class);
$this->addChild('items', Items::class);
return parent::_prepareLayout();
}

Expand Down
49 changes: 30 additions & 19 deletions app/code/Magento/Shipping/Block/Adminhtml/Create/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,53 @@
*/
namespace Magento\Shipping\Block\Adminhtml\Create;

use Magento\Backend\Block\Template\Context as TemplateContext;
use Magento\Backend\Block\Widget\Button as WidgetButton;
use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\CatalogInventory\Api\StockRegistryInterface;
use Magento\Framework\Registry;
use Magento\Sales\Block\Adminhtml\Items\AbstractItems;
use Magento\Sales\Helper\Data as SalesHelper;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Shipment as OrderShipment;
use Magento\Shipping\Model\CarrierFactory;

/**
* Adminhtml shipment items grid
*
* @api
* @since 100.0.2
*/
class Items extends \Magento\Sales\Block\Adminhtml\Items\AbstractItems
class Items extends AbstractItems
{
/**
* Sales data
*
* @var \Magento\Sales\Helper\Data
* @var SalesHelper
*/
protected $_salesData;
Copy link
Member

Choose a reason for hiding this comment

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

Why not promote this property?


/**
* @var \Magento\Shipping\Model\CarrierFactory
* @var CarrierFactory
*/
protected $_carrierFactory;
Copy link
Member

Choose a reason for hiding this comment

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

Why not promote this property?


/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
* @param \Magento\Framework\Registry $registry
* @param \Magento\Sales\Helper\Data $salesData
* @param \Magento\Shipping\Model\CarrierFactory $carrierFactory
* @param TemplateContext $context
* @param StockRegistryInterface $stockRegistry
* @param StockConfigurationInterface $stockConfiguration
* @param Registry $registry
* @param SalesHelper $salesData
* @param CarrierFactory $carrierFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
\Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
\Magento\Framework\Registry $registry,
\Magento\Sales\Helper\Data $salesData,
\Magento\Shipping\Model\CarrierFactory $carrierFactory,
TemplateContext $context,
StockRegistryInterface $stockRegistry,
StockConfigurationInterface $stockConfiguration,
Registry $registry,
SalesHelper $salesData,
CarrierFactory $carrierFactory,
array $data = []
) {
$this->_salesData = $salesData;
Expand All @@ -51,7 +62,7 @@ public function __construct(
/**
* Retrieve invoice order
*
* @return \Magento\Sales\Model\Order
* @return Order
*/
public function getOrder()
{
Expand All @@ -61,7 +72,7 @@ public function getOrder()
/**
* Retrieve source
*
* @return \Magento\Sales\Model\Order\Shipment
* @return OrderShipment
*/
public function getSource()
{
Expand All @@ -71,7 +82,7 @@ public function getSource()
/**
* Retrieve shipment model instance
*
* @return \Magento\Sales\Model\Order\Shipment
* @return OrderShipment
*/
public function getShipment()
{
Expand All @@ -87,7 +98,7 @@ protected function _beforeToHtml()
{
$this->addChild(
'submit_button',
\Magento\Backend\Block\Widget\Button::class,
WidgetButton::class,
[
'label' => __('Submit Shipment'),
'class' => 'save submit-button primary',
Expand Down
Loading