diff -u b/core/modules/book/lib/Drupal/book/Controller/BookController.php b/core/modules/book/lib/Drupal/book/Controller/BookController.php --- b/core/modules/book/lib/Drupal/book/Controller/BookController.php +++ b/core/modules/book/lib/Drupal/book/Controller/BookController.php @@ -14,6 +14,7 @@ use Drupal\node\NodeInterface; use Drupal\book\BookManager; +use Drupal\book\BookExport; /** * Controller routines for book routes. @@ -28,17 +29,25 @@ protected $bookManager; /** + * Book Export Service. + * + * @var \Drupal\book\BookExport + */ + protected $bookExport; + + /** * Injects BookManager Service. */ public static function create(ContainerInterface $container) { - return new static($container->get('book.manager')); + return new static($container->get('book.manager'), $container->get('book.export')); } /** * Constructs a BookController object. */ - public function __construct(BookManager $bookManager) { + public function __construct(BookManager $bookManager, BookExport $bookExport) { $this->bookManager = $bookManager; + $this->bookExport = $bookExport; } /** @@ -116,7 +125,7 @@ $type = Unicode::strtolower($type); // @todo Convert the custom export functionality to serializer. - $book_export_service = \Drupal::service('book.export'); + $book_export_service = $this->bookExport; $method = 'bookExport' . $type; if (!method_exists($book_export_service, $method)) { drupal_set_message(t('Unknown export format.')); @@ -128,3 +137,2 @@ - }