[Form] remove deprecated getTimezones() method

This commit is contained in:
Christian Flothmann 2015-11-28 13:08:21 +01:00
parent b5b1d504b4
commit 4a2aea0bd7

View File

@ -23,20 +23,13 @@ class TimezoneType extends AbstractType
*/ */
private static $timezones; private static $timezones;
/**
* Stores the available timezone choices.
*
* @var array
*/
private static $flippedTimezones;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults(array( $resolver->setDefaults(array(
'choices' => self::getFlippedTimezones(), 'choices' => self::getTimezones(),
'choice_translation_domain' => false, 'choice_translation_domain' => false,
)); ));
} }
@ -66,48 +59,8 @@ class TimezoneType extends AbstractType
* overhead. * overhead.
* *
* @return array The timezone choices * @return array The timezone choices
*
* @deprecated Deprecated since version 2.8
*/ */
public static function getTimezones() private static function getTimezones()
{
@trigger_error('The TimezoneType::getTimezones() method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
if (null === static::$timezones) {
static::$timezones = array();
foreach (\DateTimeZone::listIdentifiers() as $timezone) {
$parts = explode('/', $timezone);
if (count($parts) > 2) {
$region = $parts[0];
$name = $parts[1].' - '.$parts[2];
} elseif (count($parts) > 1) {
$region = $parts[0];
$name = $parts[1];
} else {
$region = 'Other';
$name = $parts[0];
}
static::$timezones[$region][$timezone] = str_replace('_', ' ', $name);
}
}
return static::$timezones;
}
/**
* Returns the timezone choices.
*
* The choices are generated from the ICU function
* \DateTimeZone::listIdentifiers(). They are cached during a single request,
* so multiple timezone fields on the same page don't lead to unnecessary
* overhead.
*
* @return array The timezone choices
*/
private static function getFlippedTimezones()
{ {
if (null === self::$timezones) { if (null === self::$timezones) {
self::$timezones = array(); self::$timezones = array();