* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; /** * Class LanguageChoiceProvider provides languages choices with ID values. * * @todo this class could be merged with \PrestaShop\PrestaShop\Core\Form\ChoiceProvider\LanguageByIdChoiceProvider * as this class can fully achieve the same behavior as the LanguageByIdChoiceProvider. * It would break BC though, so couldn't be done at the moment. */ final class LanguageChoiceProvider implements FormChoiceProviderInterface { /** * @var array */ private $languages; /** * @param array $languages */ public function __construct(array $languages) { $this->languages = $languages; } /** * Get active language choices for form. * * @return array */ public function getChoices() { $choices = []; foreach ($this->languages as $language) { $choices[$language['name']] = $language['id_lang']; } return $choices; } }