8000 [Form] remove deprecated getTimezones() method by xabbuh · Pull Request #16727 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] remove deprecated getTimezones() method #16727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 2 additions & 49 deletions src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@ class TimezoneType extends AbstractType
*/
private static $timezones;

/**
* Stores the available timezone choices.
*
* @var array
*/
private static $flippedTimezones;

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'choices' => self::getFlippedTimezones(),
'choices' => self::getTimezones(),
'choice_translation_domain' => false,
));
}
Expand All @@ -57,46 +50,6 @@ public function getBlockPrefix()
return 'timezone';
}

/**
* 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
*
* @deprecated Deprecated since version 2.8
*/
public 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.
*
Expand All @@ -107,7 +60,7 @@ public static function getTimezones()
*
* @return array The timezone choices
*/
private static function getFlippedTimezones()
private static function getTimezones()
{
if (null === self::$timezones) {
self::$timezones = array();
Expand Down
0