return $value === NULL ||
$value === '';
} /**
* {@inheritdoc}
*/
public static function generateSampleValue(FieldDefinitionInterface
$field_definition) { $random =
new Random();
$max_length =
min(UserInterface::USERNAME_MAX_LENGTH,
$field_definition->
getSetting('max_length'
));
// Generate a list of words, which can be used to generate a string.
$words =
explode(' ',
$random->
sentences(8
));
// Begin with a username that is either 2 or 3 words.
$count =
mt_rand(2, 3
);
// Capitalize the words used in usernames 50% of the time.
$words =
mt_rand(0, 1
) ?
array_map('ucfirst',
$words) :
$words;
// Username is a single long word 50% of the time. In the case of a single
// long word, sometimes the generated username may also contain periods in
// the middle of the username.
$separator = ' ';