diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index c316278..77a290b 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -6,6 +6,8 @@
*/
use Drupal\node\Plugin\Core\Entity\Node;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\entity\Plugin\Core\Entity\EntityDisplay;
use Drupal\Core\Template\Attribute;
use Drupal\menu_link\Plugin\Core\Entity\MenuLink;
@@ -168,14 +170,6 @@ function book_menu() {
'type' => MENU_SUGGESTED_ITEM,
'file' => 'book.pages.inc',
);
- $items['book/export/%/%node'] = array(
- 'page callback' => 'book_export',
- 'page arguments' => array(2, 3),
- 'access callback' => 'book_export_access',
- 'access arguments' => array(3),
- 'type' => MENU_CALLBACK,
- 'file' => 'book.pages.inc',
- );
$items['node/%node/outline'] = array(
'title' => 'Outline',
'page callback' => 'book_outline',
@@ -1373,3 +1367,39 @@ function book_library_info() {
return $libraries;
}
+
+/**
+ * Generates HTML for export when invoked by Drupal\book\Controller\BookController::export().
+ *
+ * The given node is embedded to its absolute depth in a top level section. For
+ * example, a child node with depth 2 in the hierarchy is contained in
+ * (otherwise empty)
elements corresponding to depth 0 and depth 1.
+ * This is intended to support WYSIWYG output - e.g., level 3 sections always
+ * look like level 3 sections, no matter their depth relative to the node
+ * selected to be exported as printer-friendly HTML.
+ *
+ * @param \Drupal\node\Plugin\Core\Entity\Node
+ * The node to export.
+ *
+ * @return
+ * A string containing HTML representing the node and its children in
+ * the book hierarchy.
+ *
+ * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
+ * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ */
+function book_export_html(Node $node) {
+ if (user_access('access printer-friendly version')) {
+ if (isset($node->book)) {
+ $tree = book_menu_subtree_data($node->book);
+ $contents = book_export_traverse($tree, 'book_node_export');
+ return theme('book_export_html', array('title' => $node->label(), 'contents' => $contents, 'depth' => $node->book['depth']));
+ }
+ else {
+ throw new NotFoundHttpException();
+ }
+ }
+ else {
+ throw new AccessDeniedHttpException();
+ }
+}
diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc
index a971aa6..2e8ed29 100644
--- a/core/modules/book/book.pages.inc
+++ b/core/modules/book/book.pages.inc
@@ -65,42 +65,6 @@ function book_export($type, Node $node) {
}
/**
- * Generates HTML for export when invoked by book_export().
- *
- * The given node is embedded to its absolute depth in a top level section. For
- * example, a child node with depth 2 in the hierarchy is contained in
- * (otherwise empty)
elements corresponding to depth 0 and depth 1.
- * This is intended to support WYSIWYG output - e.g., level 3 sections always
- * look like level 3 sections, no matter their depth relative to the node
- * selected to be exported as printer-friendly HTML.
- *
- * @param \Drupal\node\Plugin\Core\Entity\Node
- * The node to export.
- *
- * @return
- * A string containing HTML representing the node and its children in
- * the book hierarchy.
- *
- * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
- */
-function book_export_html(Node $node) {
- if (user_access('access printer-friendly version')) {
- if (isset($node->book)) {
- $tree = book_menu_subtree_data($node->book);
- $contents = book_export_traverse($tree, 'book_node_export');
- return theme('book_export_html', array('title' => $node->label(), 'contents' => $contents, 'depth' => $node->book['depth']));
- }
- else {
- throw new NotFoundHttpException();
- }
- }
- else {
- throw new AccessDeniedHttpException();
- }
-}
-
-/**
* Page callback: Shows the outline form for a single node.
*
* @param Drupal\node\Node $node
diff --git a/core/modules/book/book.routing.yml b/core/modules/book/book.routing.yml
new file mode 100644
index 0000000..ad0a318
--- /dev/null
+++ b/core/modules/book/book.routing.yml
@@ -0,0 +1,6 @@
+book_export:
+ pattern: '/book/export/{type}/{node}'
+ defaults:
+ _controller: '\Drupal\book\Controller\BookController::export'
+ requirements:
+ _permission: 'access printer-friendly version'
\ No newline at end of file
diff --git a/core/modules/book/lib/Drupal/book/Controller/BookController.php b/core/modules/book/lib/Drupal/book/Controller/BookController.php
new file mode 100644
index 0000000..723a1d5
--- /dev/null
+++ b/core/modules/book/lib/Drupal/book/Controller/BookController.php
@@ -0,0 +1,60 @@
+