public static function CountryItem::generateSampleValue in Country 8
Generates placeholder field values.
Useful when populating site with placeholder content during site building or profiling.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
Return value
array An associative array of values.
Overrides FieldItemBase::generateSampleValue
File
- src/
Plugin/ Field/ FieldType/ CountryItem.php, line 146
Class
- CountryItem
- Plugin implementation of the 'country' field type.
Namespace
Drupal\country\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$countries = array_keys(\Drupal::service('country.field.manager')
->getSelectableCountries($field_definition));
return [
'value' => $countries[array_rand($countries)],
];
}