예제 #1
0
 /**
  * {@inheritdoc}
  */
 public static function generateSampleValue(FieldDefinitionInterface $field_definition)
 {
     $random = new Random();
     $settings = $field_definition->getSettings();
     // Prepare destination.
     $dirname = static::doGetUploadLocation($settings);
     file_prepare_directory($dirname, FILE_CREATE_DIRECTORY);
     // Generate a file entity.
     $destination = $dirname . '/' . $random->name(10, TRUE) . '.mp4';
     $data = $random->paragraphs(3);
     $file = file_save_data($data, $destination, FILE_EXISTS_ERROR);
     $values = array('target_id' => $file->id());
     return $values;
 }