public function ExportController::exportMultiple 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::exportMultiple()
Export multiple entities to available export formats.
Parameters
\Drupal\bibcite\Plugin\BibciteFormatInterface $bibcite_format: Instance of format plugin.
string $entity_type: Entity type identifier.
\Symfony\Component\HttpFoundation\Request $request: Request object.
Return value
\Symfony\Component\HttpFoundation\Response Response object contains serialized reference data.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException Throw 404 error if Id parameter is not provided or entities not loaded.
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- modules/
bibcite_export/ src/ Controller/ ExportController.php, line 133
Class
- ExportController
- Class ExportController.
Namespace
Drupal\bibcite_export\ControllerCode
public function exportMultiple(BibciteFormatInterface $bibcite_format, $entity_type, Request $request) {
if (!$bibcite_format
->isExportFormat()) {
throw new NotFoundHttpException();
}
$storage = $this->entityTypeManager
->getStorage($entity_type);
if (!$request->query
->has('id')) {
throw new NotFoundHttpException();
}
$ids = explode(' ', $request->query
->get('id'));
$entities = $storage
->loadMultiple($ids);
if (!$entities) {
throw new NotFoundHttpException();
}
$filename = vsprintf('%s-%s', [
$entity_type,
$bibcite_format
->getLabel(),
]);
return $this
->processExport($entities, $bibcite_format, $filename);
}