You are here

public function Toc::getHeaderCount in TOC API 8

Returns a hierarchical array of headers.

Return value

array An hierarchical array of headers.

Overrides TocInterface::getHeaderCount

1 call to Toc::getHeaderCount()
Toc::isVisible in src/Toc.php
Indicates if this table of contents is visible.

File

src/Toc.php, line 373

Class

Toc
Defines A class that parses the header tags from an HTML document.

Namespace

Drupal\toc_api

Code

public function getHeaderCount() {
  if (!isset($this->headerCount)) {
    foreach ($this->index as $item) {
      if (empty($item['parent'])) {
        $this->headerCount++;
      }
    }
  }
  return $this->headerCount;
}