* @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; use PrestaShopBundle\Entity\Repository\TimezoneRepository; /** * Class TimezoneByNameChoiceProvider provides timezone choices with name values. */ final class TimezoneByNameChoiceProvider implements FormChoiceProviderInterface { /** * @var TimezoneRepository */ private $timezoneRepository; /** * @param TimezoneRepository $timezoneRepository */ public function __construct(TimezoneRepository $timezoneRepository) { $this->timezoneRepository = $timezoneRepository; } /** * Get timezone choices. * * @return array */ public function getChoices() { $timezones = $this->timezoneRepository->findAll(); $choices = []; foreach ($timezones as $timezone) { $choices[$timezone['name']] = $timezone['name']; } return $choices; } }