public static function NameItem::generateSampleValue in Name Field 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/ NameItem.php, line 288
Class
- NameItem
- Plugin implementation of the 'name' field type.
Namespace
Drupal\name\Plugin\Field\FieldTypeCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
// Single reused generation of 100 random names.
$names =& drupal_static(__FUNCTION__, []);
if (empty($names)) {
$names = \Drupal::service('name.generator')
->generateSampleNames(100, $field_definition);
}
return $names[array_rand($names)];
}