<?php
declare(strict_types=1);

namespace Autogedal\StockSourceRouter\Block\Adminhtml\Form\Field;

use Magento\Framework\View\Element\Html\Select;

class SourceSelect extends Select
{
    private const SOURCES = [
        'cron_smartbill'    => 'SmartBill',
        'cron_ptc'          => 'PTC',
        'cron_carsupreme'   => 'Carsupreme',
        'cron_alfaromtrans' => 'Alfaromtrans',
        'firebear_import'   => 'Firebear',
    ];

    public function setInputName(string $value): self
    {
        return $this->setName($value);
    }

    public function setInputId(string $value): self
    {
        return $this->setId($value);
    }

    protected function _toHtml(): string
    {
        if (!$this->getOptions()) {
            $options = [['value' => '', 'label' => __('-- Select --')]];
            foreach (self::SOURCES as $value => $label) {
                $options[] = ['value' => $value, 'label' => $label];
            }
            $this->setOptions($options);
        }
        return parent::_toHtml();
    }
}
