public function ContactStorageExportService::encode in Contact Storage Export 8
Returns the encoded contact messages.
Parameters
\Drupal\contact\MessageInterface[] $messages: The messages.
string[] $settings: The settings array.
string $format: (optional) The encoding format. Defaults to CSV.
Return value
string The encoded data.
File
- src/
ContactStorageExportService.php, line 266
Class
- ContactStorageExportService
- Provides a set of methods to export contact messages in CSV format.
Namespace
Drupal\contact_storage_exportCode
public function encode(array $messages, array $settings = [], $format = 'csv') {
$data = [];
// Get labels.
if (!isset($settings['labels'])) {
$message = reset($messages);
$settings['labels'] = $this
->getLabels($message);
}
// Iterate over contact message and get serialized data.
foreach ($messages as $message) {
$data[] = $this
->serialize($message, $settings);
}
return $this
->encodeData($data, $format);
}