<?php

namespace App\Form\Input;

class CustomerFlag extends \Engine\Form\Input\Flag
{

	/**
	 * Determines the possible values for a specific configuration or option based on predefined flags.
	 *
	 * Retrieves a list of flags from the configuration and compiles them into an array of options.
	 * Additionally, includes a "no flag" option if it has been specified.
	 *
	 * @return array An associative array where keys represent flag codes, and values are arrays containing 'icon' and 'label' for each option.
	 */
	protected function determinePossibleValues() :array
	{
		$flagsList = \App\Config\CustomersFlags::getInstance()->getAll();
		$return = [];
		// add the "no flag" option if it is set
		if ($this->showDefaultOption) {
			$return[''] = [ 'icon'=>'None', 'label'=>$this->defaultOptionText ];
		}
		// add the flags from the configuration
		if ($flagsList) {
			foreach ($flagsList as $flagCode => $flagName) {
				$return[$flagCode] = [ 'icon'=>$flagCode, 'label'=>$flagName ];
			}
		}
		return $return;
	}

}
