. */ namespace Storefront\BTCPay\Model\Config\Source; class BtcPayStore implements \Magento\Framework\Data\OptionSourceInterface { /** * @var \Storefront\BTCPay\Model\BTCPay\BTCPayService */ private $btcPayService; public function __construct(\Storefront\BTCPay\Model\BTCPay\BTCPayService $btcPayService) { $this->btcPayService = $btcPayService; } public function toOptionArray() { $r = []; $magentoStoreId = $this->btcPayService->getCurrentMagentoStoreId(); $baseUrl = $this->btcPayService->getBtcPayServerBaseUrl(); $apiKey = $this->btcPayService->getApiKey('default', 0); $stores = $this->btcPayService->getAllBtcPayStores($baseUrl, $apiKey); $r[] = ''; if ($stores) { foreach ($stores as $store) { $r[$store['id']] = $store['name']; } } return $r; } }