protected function ExportController::processExport in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_export/src/Controller/ExportController.php \Drupal\bibcite_export\Controller\ExportController::processExport()
Serialize and create response contains file in selected format.
Parameters
array $entities: Array of entities objects.
\Drupal\bibcite\Plugin\BibciteFormatInterface $bibcite_format: Instance of format plugin.
null|string $filename: Filename. Will be generated if not provided.
Return value
\Symfony\Component\HttpFoundation\Response Response object contains serialized reference data.
2 calls to ExportController::processExport()
- ExportController::export in modules/
bibcite_export/ src/ Controller/ ExportController.php - Export entity to available export format.
- ExportController::exportMultiple in modules/
bibcite_export/ src/ Controller/ ExportController.php - Export multiple entities to available export formats.
File
- modules/
bibcite_export/ src/ Controller/ ExportController.php, line 68
Class
- ExportController
- Class ExportController.
Namespace
Drupal\bibcite_export\ControllerCode
protected function processExport(array $entities, BibciteFormatInterface $bibcite_format, $filename = NULL) {
if (!$filename) {
$filename = $bibcite_format
->getLabel();
}
$response = new Response();
if ($result = $this->serializer
->serialize($entities, $bibcite_format
->getPluginId())) {
$response->headers
->set('Cache-Control', 'no-cache');
$response->headers
->set('Content-type', 'text/plain');
$response->headers
->set('Content-Disposition', 'attachment; filename="' . $filename . '.' . $bibcite_format
->getExtension() . '";');
$response
->sendHeaders();
$result = is_array($result) ? implode("\n", $result) : $result;
$response
->setContent($result);
}
return $response;
}