<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ /** * Config Directory currency backend model * Allows dispatching before and after events for each controller action */ namespace Magento\Config\Model\Config\Backend\Currency; /** * @api * @since 100.0.2 */ class DefaultCurrency extends AbstractCurrency { /** * Check default currency is available in installed currencies * Check default currency is available in allowed currencies * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function afterSave() { if (!in_array($this->getValue(), $this->_getInstalledCurrencies())) { throw new \Magento\Framework\Exception\LocalizedException( __('Sorry, we haven\'t installed the default display currency you selected.') ); } if (!in_array($this->getValue(), $this->_getAllowedCurrencies())) { throw new \Magento\Framework\Exception\LocalizedException( __('Sorry, the default display currency you selected is not available in allowed currencies.') ); } return parent::afterSave(); } }