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:----NNlwRqfiSoXswGl5OAQgEm2UvXyGPAqnhrzy2eHDmIh7K3+6f6IpRyUqgWUHGAGjUM9co+b0K3nHdVq3+v0UXcPL8MsFYfiuNnUljX8NoT36rylYgWLX9MsWt9jVtfDC3jR5n/NRxWdo/QY9rD1w0yqJ7e1LY41h0Sba3cpWhQYL2LaA3CrYm4x4mF+CgRdNvqwz3ZTmUc030BNN6rEipm7XGYiMLpn+Ul0pDAq3YtU2HSd9SHDTOCj0TRKojpJBjnyuxpDJekPBgmgEpYrhXdjhClwH5bJy1McPLpUasDI0gD0VwQ7kJaYsvgb3A1IjCZWm6v66sXEYudF18hX2vleT3qY58G9YqCXLvEeJB3mTlEv/B4+7Nc/C3AYw4cxOs2cGeqXmptkD/y40OaBuzglY2sEEhUtTlsVx3Xz/GENU3pzBvkWa1Zp824dHUerPTgGcOF2FcgRafAhwEbvw3TBWwDZ52+y8s57deSTSt5Oqt+xGHC8Yz30K2++bUQtfhY7H45AmtMkPidobu8PwEcCyZLi6k2ZW0lT3byoBCsjEHpeDJzd03rHFWACotEhYyagJLB1aFSIPE0h8DBIrEkXzhH6eRmbY6nHsZYhuQgcGHvFkKx70f1e/SlcNU5A2TZKuRf5iIxGeOfh5uuISCjLNFRyMo4waaj5VOYF0mZI=----ATTACHMENT:----NTMxOTkwNzY5NzAwNjI5NSA5MTkzNTM2MzQ2OTEyMDUgNzgwMTUyMDE2Njc0NDQ1Nw==