You are here

public static function SimpleIframeFieldType::generateSampleValue in Simple iframe 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/SimpleIframeFieldType.php, line 86

Class

SimpleIframeFieldType
Plugin implementation of the 'simple_iframe_field_type' field type.

Namespace

Drupal\simple_iframe\Plugin\Field\FieldType

Code

public static function generateSampleValue(FieldDefinitionInterface $field_definition) {

  // Set of possible top-level domains.
  $tlds = [
    'com',
    'net',
    'org',
  ];

  // Set random length for the domain name.
  $domain_length = mt_rand(7, 15);
  $random = new Random();
  $values['url'] = '//' . $random
    ->word($domain_length) . '.' . $tlds[mt_rand(0, count($tlds) - 1)];
  return $values;
}