public static function UserNameItem::generateSampleValue in Drupal 8
Same name and namespace in other branches
- 9 core/modules/user/src/UserNameItem.php \Drupal\user\UserNameItem::generateSampleValue()
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 StringItem::generateSampleValue
File
- core/
modules/ user/ src/ UserNameItem.php, line 30
Class
- UserNameItem
- Defines a custom field item class for the 'name' user entity field.
Namespace
Drupal\userCode
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$values = parent::generateSampleValue($field_definition);
// User names larger than 60 characters won't pass validation.
$values['value'] = substr($values['value'], 0, UserInterface::USERNAME_MAX_LENGTH);
return $values;
}