You are here

public function ExportController::export in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_export/src/Controller/ExportController.php \Drupal\bibcite_export\Controller\ExportController::export()

Export entity to available export format.

Parameters

\Drupal\bibcite\Plugin\BibciteFormatInterface $bibcite_format: Instance of format plugin.

string $entity_type: Entity type identifier.

\Drupal\Core\Entity\EntityInterface $entity: Entity object.

Return value

\Symfony\Component\HttpFoundation\Response Response object contains serialized reference data.

1 string reference to 'ExportController::export'
bibcite_export.routing.yml in modules/bibcite_export/bibcite_export.routing.yml
modules/bibcite_export/bibcite_export.routing.yml

File

modules/bibcite_export/src/Controller/ExportController.php, line 102

Class

ExportController
Class ExportController.

Namespace

Drupal\bibcite_export\Controller

Code

public function export(BibciteFormatInterface $bibcite_format, $entity_type, EntityInterface $entity) {
  if (!$entity
    ->access('view')) {
    throw new AccessDeniedHttpException();
  }
  if (!$bibcite_format
    ->isExportFormat()) {
    throw new NotFoundHttpException();
  }
  $filename = vsprintf('%s-%s-%s', [
    $entity_type,
    $entity
      ->id(),
    $bibcite_format
      ->getLabel(),
  ]);
  return $this
    ->processExport([
    $entity,
  ], $bibcite_format, $filename);
}