public BookController::bookExport($type, NodeInterface $node)
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
File
- core/modules/book/src/Controller/BookController.php, line 152
Class
- BookController
- Controller routines for book routes.
Namespace
Drupal\book\Controller
Code
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)) { drupal_set_message(t('Unknown export format.')); throw new NotFoundHttpException(); } $exported_book = $this->bookExport->{$method}($node); return new Response($this->renderer->renderRoot($exported_book)); }
Please login to continue.