You are here

public static function PathItem::generateSampleValue in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/path/src/Plugin/Field/FieldType/PathItem.php \Drupal\path\Plugin\Field\FieldType\PathItem::generateSampleValue()
  2. 10 core/modules/path/src/Plugin/Field/FieldType/PathItem.php \Drupal\path\Plugin\Field\FieldType\PathItem::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 FieldItemBase::generateSampleValue

File

core/modules/path/src/Plugin/Field/FieldType/PathItem.php, line 109

Class

PathItem
Defines the 'path' entity field type.

Namespace

Drupal\path\Plugin\Field\FieldType

Code

public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
  $random = new Random();
  $values['alias'] = '/' . str_replace(' ', '-', strtolower($random
    ->sentences(3)));
  return $values;
}