function TimeZoneItem::generateSampleValue
Same name in other branches
- 8.9.x core/modules/user/src/TimeZoneItem.php \Drupal\user\TimeZoneItem::generateSampleValue()
- 10 core/modules/user/src/TimeZoneItem.php \Drupal\user\TimeZoneItem::generateSampleValue()
- 11.x core/modules/user/src/TimeZoneItem.php \Drupal\user\TimeZoneItem::generateSampleValue()
Overrides StringItem::generateSampleValue
File
-
core/
modules/ user/ src/ TimeZoneItem.php, line 17
Class
- TimeZoneItem
- Defines a custom field item class for the 'timezone' user entity field.
Namespace
Drupal\userCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$timezones = User::getAllowedTimezones();
// We need to vary the selected timezones since we're generating a sample.
$key = rand(0, count($timezones) - 1);
return $timezones[$key];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.