Skip to content

Commit cb16856

Browse files
author
Oleksii Korshenko
committed
Merge remote-tracking branch 'origin/MAGETWO-50789-Fix-incorrect-getter-methods' into bug-fixes
2 parents c3ebd10 + 5add111 commit cb16856

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

app/code/Magento/Backend/Helper/Dashboard/Order.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ public function __construct(
3535
}
3636

3737
/**
38-
* @return \Magento\SalesRule\Model\RuleFactory
38+
* The getter function to get the new StoreManager dependency
39+
*
40+
* @return \Magento\Store\Model\StoreManagerInterface
41+
*
3942
* @deprecated
4043
*/
41-
public function getStoreManager()
44+
private function getStoreManager()
4245
{
43-
if ($this->_storeManager instanceof \Magento\Store\Model\StoreManagerInterface) {
44-
$this->_storeManager = ObjectManager::getInstance()->get('\Magento\Store\Model\StoreManagerInterface');
46+
if ($this->_storeManager === null) {
47+
$this->_storeManager = ObjectManager::getInstance()->get('Magento\Store\Model\StoreManagerInterface');
4548
}
49+
return $this->_storeManager;
4650
}
4751

4852
/**
@@ -57,15 +61,15 @@ protected function _initCollection()
5761
if ($this->getParam('store')) {
5862
$this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
5963
} elseif ($this->getParam('website')) {
60-
$storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
64+
$storeIds = $this->getStoreManager()->getWebsite($this->getParam('website'))->getStoreIds();
6165
$this->_collection->addFieldToFilter('store_id', ['in' => implode(',', $storeIds)]);
6266
} elseif ($this->getParam('group')) {
63-
$storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
67+
$storeIds = $this->getStoreManager()->getGroup($this->getParam('group'))->getStoreIds();
6468
$this->_collection->addFieldToFilter('store_id', ['in' => implode(',', $storeIds)]);
6569
} elseif (!$this->_collection->isLive()) {
6670
$this->_collection->addFieldToFilter(
6771
'store_id',
68-
['eq' => $this->_storeManager->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()]
72+
['eq' => $this->getStoreManager()->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()]
6973
);
7074
}
7175
$this->_collection->load();

app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Actions.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,18 @@ public function __construct(
6565
}
6666

6767
/**
68+
* The getter function to get the new RuleFactory dependency
69+
*
6870
* @return \Magento\SalesRule\Model\RuleFactory
71+
*
6972
* @deprecated
7073
*/
71-
public function getRuleFactory()
74+
private function getRuleFactory()
7275
{
73-
if ($this->ruleFactory instanceof \Magento\SalesRule\Model\RuleFactory) {
74-
$this->ruleFactory = ObjectManager::getInstance()->get('\Magento\SalesRule\Model\RuleFactory');
76+
if ($this->ruleFactory === null) {
77+
$this->ruleFactory = ObjectManager::getInstance()->get('Magento\SalesRule\Model\RuleFactory');
7578
}
79+
return $this->ruleFactory;
7680
}
7781

7882
/**
@@ -165,7 +169,7 @@ protected function addTabToForm($model, $fieldsetId = 'actions_fieldset', $formN
165169
{
166170
if (!$model) {
167171
$id = $this->getRequest()->getParam('id');
168-
$model = $this->ruleFactory->create();
172+
$model = $this->getRuleFactory()->create();
169173
$model->load($id);
170174
}
171175

app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ public function __construct(
5656
}
5757

5858
/**
59+
* The getter function to get the new RuleFactory dependency
60+
*
5961
* @return \Magento\SalesRule\Model\RuleFactory
62+
*
6063
* @deprecated
6164
*/
62-
public function getRuleFactory()
65+
private function getRuleFactory()
6366
{
64-
if ($this->ruleFactory instanceof \Magento\SalesRule\Model\RuleFactory) {
65-
$this->ruleFactory = ObjectManager::getInstance()->get('\Magento\SalesRule\Model\RuleFactory');
67+
if ($this->ruleFactory === null) {
68+
$this->ruleFactory = ObjectManager::getInstance()->get('Magento\SalesRule\Model\RuleFactory');
6669
}
70+
return $this->ruleFactory;
6771
}
6872

6973
/**
@@ -156,7 +160,7 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
156160
{
157161
if (!$model) {
158162
$id = $this->getRequest()->getParam('id');
159-
$model = $this->ruleFactory->create();
163+
$model = $this->getRuleFactory()->create();
160164
$model->load($id);
161165
}
162166
$conditionsFieldSetId = $model->getConditionsFieldSetId($formName);

0 commit comments

Comments
 (0)