Skip to content

Commit 8e3b570

Browse files
coderimusrostyslav-hymon
authored andcommitted
Backward compatible: adding a constructor parameter
1 parent 359a647 commit 8e3b570

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

app/code/Magento/Sales/Block/Order/Recent.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Customer\Model\Session;
1111
use Magento\Sales\Model\Order\Config;
1212
use Magento\Store\Model\StoreManagerInterface;
13+
use Magento\Framework\App\ObjectManager;
1314

1415
/**
1516
* Sales order history block
@@ -57,15 +58,16 @@ public function __construct(
5758
CollectionFactory $orderCollectionFactory,
5859
Session $customerSession,
5960
Config $orderConfig,
60-
StoreManagerInterface $storeManager,
61-
array $data = []
61+
array $data = [],
62+
StoreManagerInterface $storeManager = null
6263
) {
6364
$this->_orderCollectionFactory = $orderCollectionFactory;
6465
$this->_customerSession = $customerSession;
6566
$this->_orderConfig = $orderConfig;
66-
$this->storeManager = $storeManager;
67-
parent::__construct($context, $data);
6867
$this->_isScopePrivate = true;
68+
$this->storeManager = $storeManager ?: ObjectManager::getInstance()
69+
->get(StoreManagerInterface::class);
70+
parent::__construct($context, $data);
6971
}
7072

7173
/**

app/code/Magento/Sales/Test/Unit/Block/Order/RecentTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ protected function setUp()
6464

6565
public function testConstructMethod()
6666
{
67-
$data = [];
6867
$attribute = ['customer_id', 'store_id', 'status'];
6968
$customerId = 25;
7069
$storeId = 4;
@@ -130,8 +129,8 @@ public function testConstructMethod()
130129
$this->orderCollectionFactory,
131130
$this->customerSession,
132131
$this->orderConfig,
133-
$this->storeManagerMock,
134-
$data
132+
[],
133+
$this->storeManagerMock
135134
);
136135
$this->assertEquals($orderCollection, $this->block->getOrders());
137136
}

0 commit comments

Comments
 (0)