<?php

/*
 * @component UserPoints
 * @copyright Copyright (C) 2015-2022 Bernard Gilly - Adrien Roussel - Martin Brampton
 * extension menu created by Mike Gusev (migus)
 * @license : GNU/GPL
 * @Website : https://remository.com
 */

namespace BlackSheepResearch\Component\UserPoints\Administrator\Field;

// no direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Form\Field\ListField;

class PayageCurrencyField extends ListField {

    /**
     * The field type.
     */
    protected $type = 'PayageCurrency';

    protected function getOptions() {
        $pagapi = JPATH_ADMINISTRATOR . '/components/com_payage/api.php';
        if (file_exists($pagapi)) {
            require_once $pagapi;
            $currency_list = \PayageApi::Get_Currencies(0);
            $options = [];
            foreach ($currency_list as $currency) {
                $options[] = array("value" => $currency, "text" => $currency);
            }
            return array_merge(parent::getOptions(), $options);
        }
        return parent::getOptions();
    }
}
