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:----pcV7W6ZCDWTe5EdXwx3u1+VhkHuWwFy9pwEyhMMBsje6FVQt+uQsrUV0oNHVOUB++vdcFEzb3fZGZmZ6BJu7LLv7lHcxzRN74LoPy0By3xqAH6cK8k7h5YebUOlE7pLeQNToPCf6fem1bjyCpkxTkI1ptTEu3+o6UckL9TTDqfvT0PNrsMOZZzY6+xQlAfgOi8XhdpDjfTzs42xPDUxReeIZgAtQrsUjlra4Rz1vh3TJA5SSoRP3qnT+UwHJ4+0MfF3jhBbCC6m2ufTfQycT2Li7pPmih7cj74/5VfWQpB92PQdh0XNhUUIWUNH/bcDqRIHnK2TCmxJXYGuSr3O6jFbW5jQRVVqn66CUzDifu+vFQzyyf+nV/9Gl0DBgaHXI9JJxnglYaDQHJ10PQvUlCVgKxe0N3DocJeoDD9JCvDiPVcWbwrw3vHLlEqyu6dYZxjrvfV6ngs1ANymYbYlmCo1AwJvG7xkuW6oc5CZG30IECcw9bBfJKjkQHiUmH2KZB9dvqSxzp/31veMHw7X5ZeAnrNC0mjbj8QVVA2n5isqSy0Uu2dZYNVVei8dFdmSv1IGO30FU5GiwSN5e2Dttu7AJWBCsb7c+N5OEST9/k7JKaVyuXiRSonqSVRGXxVXB40tVHyvaqf+A/4UXLw/ycK2CqtSwS/IuwU43gjcqYNU=----ATTACHMENT:----NzYzNTU5MDQyNDIwOTM3OCA0MzU0MDEyMDA0OTM0MjYyIDUzNDk2Mzc3ODY2NDM2NzI=