Mercurial > hg > isophonics-drupal-site
view core/modules/user/src/TimeZoneItem.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
line wrap: on
line source
<?php namespace Drupal\user; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\StringItem; use Drupal\user\Entity\User; /** * Defines a custom field item class for the 'timezone' user entity field. */ class TimeZoneItem extends StringItem { /** * {@inheritdoc} */ 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]; } }