requestStack = $request_stack; } /** * {@inheritdoc} */ public static function getLabel() { return t("Book navigation"); } /** * {@inheritdoc} */ public function getContext() { // Find the current book's ID. $current_bid = 0; if ($node = $this->requestStack->getCurrentRequest()->get('node')) { $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid']; } // If we're not looking at a book node, then we're not navigating a book. if ($current_bid === 0) { return 'book.none'; } // If we're looking at a book node, get the trail for that node. $active_trail = $this->container->get('book.manager') ->getActiveTrailIds($node->book['bid'], $node->book); return 'book.' . implode('|', $active_trail); } }