44 * See COPYING.txt for license details.
55 */
66
7- // @codingStandardsIgnoreFile
8-
97/**
108 * Backend Directory currency backend model
119 * Allows dispatching before and after events for each controller action
1412
1513class Base extends AbstractCurrency
1614{
17- /** @var \Magento\Directory\Model\Currency */
18- private $ currency ;
15+ /** @var \Magento\Directory\Model\CurrencyFactory */
16+ private $ currencyFactory ;
1917
2018 /**
2119 * @param \Magento\Framework\Model\Context $context
2220 * @param \Magento\Framework\Registry $registry
2321 * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
2422 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
25- * @param \Magento\Directory\Model\Currency $currency
23+ * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
2624 * @param \Magento\Framework\Model\Resource\AbstractResource $resource
2725 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
2826 * @param array $data
@@ -32,14 +30,15 @@ public function __construct(
3230 \Magento \Framework \Registry $ registry ,
3331 \Magento \Framework \App \Config \ScopeConfigInterface $ config ,
3432 \Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
35- \Magento \Directory \Model \Currency $ currency ,
33+ \Magento \Directory \Model \CurrencyFactory $ currencyFactory ,
3634 \Magento \Framework \Model \Resource \AbstractResource $ resource = null ,
3735 \Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
3836 array $ data = []
3937 ) {
4038 parent ::__construct ($ context , $ registry , $ config , $ scopeConfig , $ resource , $ resourceCollection , $ data );
41- $ this ->currency = $ currency ;
39+ $ this ->currencyFactory = $ currencyFactory ;
4240 }
41+
4342 /**
4443 * Check base currency is available in installed currencies
4544 *
@@ -50,10 +49,12 @@ public function afterSave()
5049 {
5150 $ value = $ this ->getValue ();
5251 if (!in_array ($ value , $ this ->_getInstalledCurrencies ())) {
53- throw new \Magento \Framework \Exception \LocalizedException (__ ('Sorry, we haven \'t installed the base currency you selected. ' ));
52+ throw new \Magento \Framework \Exception \LocalizedException (
53+ __ ('Sorry, we haven \'t installed the base currency you selected. ' ));
54+
5455 }
5556
56- $ this ->currency ->saveRates ([$ value =>[$ value => 1 ]]);
57+ $ this ->currencyFactory -> create () ->saveRates ([$ value =>[$ value => 1 ]]);
5758 return $ this ;
5859 }
5960}
0 commit comments