[Form] fixed CS

This commit is contained in:
Fabien Potencier 2011-05-11 10:08:59 +02:00
parent 534cf8fce7
commit 723a8f2bf3

View File

@ -22,7 +22,7 @@ class TimezoneChoiceList implements ChoiceListInterface
* Stores the available timezone choices * Stores the available timezone choices
* @var array * @var array
*/ */
protected static $timezones; static protected $timezones;
/** /**
* Returns the timezone choices. * Returns the timezone choices.
@ -32,31 +32,34 @@ class TimezoneChoiceList implements ChoiceListInterface
* so multiple timezone fields on the same page don't lead to unnecessary * so multiple timezone fields on the same page don't lead to unnecessary
* overhead. * overhead.
* *
* @return array The timezone choices * @return array The timezone choices
*/ */
public function getChoices() public function getChoices()
{ {
if (count(static::$timezones) == 0) { if (null !== static::$timezones) {
foreach (\DateTimeZone::listIdentifiers() as $timezone) { return static::$timezones;
$parts = explode('/', $timezone); }
if (count($parts) > 2) { static::$timezones = array();
$region = $parts[0]; foreach (\DateTimeZone::listIdentifiers() as $timezone) {
$name = $parts[1].' - '.$parts[2]; $parts = explode('/', $timezone);
} else if (count($parts) > 1) {
$region = $parts[0];
$name = $parts[1];
} else {
$region = 'Other';
$name = $parts[0];
}
if (!isset(static::$timezones[$region])) { if (count($parts) > 2) {
static::$timezones[$region] = array(); $region = $parts[0];
} $name = $parts[1].' - '.$parts[2];
} else if (count($parts) > 1) {
static::$timezones[$region][$timezone] = str_replace('_', ' ', $name); $region = $parts[0];
$name = $parts[1];
} else {
$region = 'Other';
$name = $parts[0];
} }
if (!isset(static::$timezones[$region])) {
static::$timezones[$region] = array();
}
static::$timezones[$region][$timezone] = str_replace('_', ' ', $name);
} }
return static::$timezones; return static::$timezones;