public function pushSection(JsonFormatSectionNode $section) { $stackPos = 1; for (; $stackPos < sizeof($this->jsonStack); $stackPos++) { $stackElement = $this->jsonStack[$stackPos]; if (!$stackElement instanceof JsonFormatSectionNode || $stackElement->getLevel() >= $section->getLevel()) { break; } } $this->jsonStack = array_slice($this->jsonStack, 0, $stackPos); $this->pushNode($section); }
/** * @param $article * @param $htmlParser * @return JsonFormatSectionNode */ protected function parseArticleToSection($article, $htmlParser, $tabTitle) { $html = $article->getPage()->getParserOutput(\ParserOptions::newFromContext(new RequestContext()))->getText(); $jsonArticle = $htmlParser->parse($html); $tabSection = new JsonFormatSectionNode(1, $tabTitle); foreach ($jsonArticle->getChildren() as $child) { $tabSection->addChild($child); } return $tabSection; }