ConfigProvider.php (2268B)
1 <?php 2 /** 3 * 4 * This file is part of TALER 5 * Copyright (C) 2024 Taler Systems SA 6 * 7 * TALER is free software; you can redistribute it and/or modify it under the 8 * terms of the GNU General Public License as published by the Free Software 9 * Foundation; either version 3, or (at your option) any later version. 10 * 11 * TALER is distributed in the hope that it will be useful, but WITHOUT ANY 12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along with 16 * TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 17 * 18 * @author Nicola Eigel 19 */ 20 21 namespace GNU\Taler\Model; 22 23 use Magento\Checkout\Model\ConfigProviderInterface; 24 use Magento\Framework\App\Config\ScopeConfigInterface; 25 use Magento\Store\Model\ScopeInterface; 26 use Magento\Framework\App\Config\Storage\WriterInterface; 27 28 class ConfigProvider implements ConfigProviderInterface 29 { 30 const CODE = 'gnu_taler'; 31 32 /** 33 * @var ScopeConfigInterface 34 */ 35 protected $_scopeConfig; 36 37 const XML_PATH_SETTING_DATA = 'payment/gnu_taler'; 38 /** 39 * @var WriterInterface 40 */ 41 private $_configWriter; 42 43 /** 44 * @param ScopeConfigInterface $scopeConfig 45 * @param WriterInterface $configWriter 46 */ 47 public function __construct( 48 ScopeConfigInterface $scopeConfig, 49 WriterInterface $configWriter 50 ) 51 { 52 $this->_scopeConfig = $scopeConfig; 53 $this->_configWriter = $configWriter; 54 } 55 56 /** 57 * Returns needed config details to dependencies 58 * @return \array[][] 59 */ 60 public function getConfig() 61 { 62 $storeScope = ScopeInterface::SCOPE_STORE; 63 $config = $this->_scopeConfig->getValue(self::XML_PATH_SETTING_DATA, $storeScope); 64 $this->_configWriter->save(self::XML_PATH_SETTING_DATA, "payment_url", $storeScope); 65 $result = []; 66 $result['logo_url'] = $config['logo_url']; 67 $result['backend_url'] = $config['backend_url']; 68 $result['currency'] = $config['currency']; 69 70 return [ 71 'payment' => [ 72 self::CODE => $result 73 ] 74 ]; 75 } 76 }