function BookController::bookExport
Same name in other branches
- 9 core/modules/book/src/Controller/BookController.php \Drupal\book\Controller\BookController::bookExport()
- 10 core/modules/book/src/Controller/BookController.php \Drupal\book\Controller\BookController::bookExport()
- 11.x core/modules/book/src/Controller/BookController.php \Drupal\book\Controller\BookController::bookExport()
Generates representations of a book page and its children.
The method delegates the generation of output to helper methods. The method name is derived by prepending 'bookExport' to the camelized form of given output type. For example, a type of 'html' results in a call to the method bookExportHtml().
Parameters
string $type: A string encoding the type of output requested. The following types are currently supported in book module:
- html: Printer-friendly HTML.
Other types may be supported in contributed modules.
\Drupal\node\NodeInterface $node: The node to export.
Return value
array A render array representing the node and its children in the book hierarchy in a format determined by the $type parameter.
Throws
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
1 string reference to 'BookController::bookExport'
- book.routing.yml in core/
modules/ book/ book.routing.yml - core/modules/book/book.routing.yml
File
-
core/
modules/ book/ src/ Controller/ BookController.php, line 153
Class
- BookController
- Controller routines for book routes.
Namespace
Drupal\book\ControllerCode
public function bookExport($type, NodeInterface $node) {
$method = 'bookExport' . Container::camelize($type);
// @todo Convert the custom export functionality to serializer.
if (!method_exists($this->bookExport, $method)) {
$this->messenger()
->addStatus(t('Unknown export format.'));
throw new NotFoundHttpException();
}
$exported_book = $this->bookExport
->{$method}($node);
return new Response($this->renderer
->renderRoot($exported_book));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.