Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/src/TimeZoneItem.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
| author | Chris Cannam |
|---|---|
| date | Mon, 23 Apr 2018 09:46:53 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 13:5fb285c0d0e3 | 14:1fec387a4317 |
|---|---|
| 1 <?php | |
| 2 | |
| 3 namespace Drupal\user; | |
| 4 | |
| 5 use Drupal\Core\Field\FieldDefinitionInterface; | |
| 6 use Drupal\Core\Field\Plugin\Field\FieldType\StringItem; | |
| 7 use Drupal\user\Entity\User; | |
| 8 | |
| 9 /** | |
| 10 * Defines a custom field item class for the 'timezone' user entity field. | |
| 11 */ | |
| 12 class TimeZoneItem extends StringItem { | |
| 13 | |
| 14 /** | |
| 15 * {@inheritdoc} | |
| 16 */ | |
| 17 public static function generateSampleValue(FieldDefinitionInterface $field_definition) { | |
| 18 $timezones = User::getAllowedTimezones(); | |
| 19 // We need to vary the selected timezones since we're generating a sample. | |
| 20 $key = rand(0, count($timezones) - 1); | |
| 21 return $timezones[$key]; | |
| 22 } | |
| 23 | |
| 24 } |
