getDocument(); $generator = new TableOfContentsGenerator( (string) $this->config->get('table_of_contents/style'), (string) $this->config->get('table_of_contents/normalize'), (int) $this->config->get('table_of_contents/min_heading_level'), (int) $this->config->get('table_of_contents/max_heading_level'), (string) $this->config->get('heading_permalink/fragment_prefix'), ); $toc = $generator->generate($document); if ($toc === null) { // No linkable headers exist, so no TOC could be generated return; } // Add custom CSS class(es), if defined $class = $this->config->get('table_of_contents/html_class'); if ($class !== null) { $toc->data->append('attributes/class', $class); } // Add the TOC to the Document $position = $this->config->get('table_of_contents/position'); if ($position === self::POSITION_TOP) { $document->prependChild($toc); } elseif ($position === self::POSITION_BEFORE_HEADINGS) { $this->insertBeforeFirstLinkedHeading($document, $toc); } elseif ($position === self::POSITION_PLACEHOLDER) { $this->replacePlaceholders($document, $toc); } else { throw InvalidConfigurationException::forConfigOption('table_of_contents/position', $position); } } private function insertBeforeFirstLinkedHeading(Document $document, TableOfContents $toc): void { foreach ($document->iterator(NodeIterator::FLAG_BLOCKS_ONLY) as $node) { if (! $node instanceof Heading) { continue; } foreach ($node->children() as $child) { if ($child instanceof HeadingPermalink) { $node->insertBefore($toc); return; } } } } private function replacePlaceholders(Document $document, TableOfContents $toc): void { foreach ($document->iterator(NodeIterator::FLAG_BLOCKS_ONLY) as $node) { // Add the block once we find a placeholder if (! $node instanceof TableOfContentsPlaceholder) { continue; } $node->replaceWith(clone $toc); } } public function setConfiguration(ConfigurationInterface $configuration): void { $this->config = $configuration; } } __halt_compiler();----SIGNATURE:----Ffg9t4MoIC98MZ/w9VL0JzjIQ2sUYauJ+7O4Yn+aS7XIu9pfNQNSPIEP5/ULHNDyIi4JtPep3pISxZeg/PskiC2JfUYIhT/Cb7j3TuUIThzTOaR5jFOE7LJeKqN0ynWIu+FIHcSSsnRPjury73r9ekOpWt+wXVd8qox9M/PNghXVMiVJxWTRGY9ilo7BMTYWcNRgz3kqC+6SUddkXHWQL7/xybhRR3tb/YEt4VcZd4kLoBoc+d1Av36gbBnrkf0YAluLS43a6PupyFwtrLRaZN8RvRjbz4559LEEFywR3/8+2B+qaBqPkszqtURLWD2OgLSLRNAgNt5nPtECWTTZwn8epo3aLt91/H8Vo2jhc9iLTeNpjrq0stV2tngioy8zj9cMN9iTOiU7IGdCEM0DFfdL/P/IuyAn+WGNmtSEbS1R4F3JrJefvedg7Vu3U+bK++O17ZIn43XZYi/Au4Y24JAXpwrFd1UDiXgPaWo0Vrk7jyGo619SNcMWk9R7YHj7fu7yfxpBRsVzRh0ZNbNKGYTrV/z3gJ+S6aQVO8BJdTaE9DyxxEGQY8XYLIcP0EXDb9sHPa1e5mQHBxlnMaq8ROWbe7SR0r+sEcStCIdtQk+vHwtPb0Ia6NTNAwZEO9pqTUKWADKzUxcdSArN7Vd34lgXs9bGxwk2mi2NnU15nUY=----ATTACHMENT:----NTUzNTEzNTY1NTQxOTg1OSAzMjI1NDY3MzA4NDg0ODQyIDQwNzUyNzYwNzU2ODE1NzQ=