/** * Bakes the given page. Additional template data can be provided, along with * a specific set of posts for the pagination data. */ public function bake(IPage $page, array $extraData = null) { $didBake = false; try { $this->bakedFiles = array(); $this->paginationDataAccessed = false; $this->logger->debug("Baking '{$page->getUri()}'..."); $pageRenderer = new PageRenderer($page); $hasMorePages = true; while ($hasMorePages) { $didBakeThisOne = $this->bakeSinglePage($pageRenderer, $extraData); $didBake |= $didBakeThisOne; if (!$didBakeThisOne) { break; } $data = $page->getPageData(); if ($data and isset($data['pagination'])) { $paginator = $data['pagination']; $hasMorePages = ($paginator->wasPaginationDataAccessed() and $paginator->hasMorePages()); if ($hasMorePages) { $page->setPageNumber($page->getPageNumber() + 1); // setPageNumber() resets the page's data, so when we // enter bakeSinglePage again in the next loop, we have // to re-set the extraData and all other stuff. } } } } catch (Exception $e) { $pageRelativePath = PageHelper::getRelativePath($page); throw new PieCrustException("Error baking page '{$pageRelativePath}' (p{$page->getPageNumber()})", 0, $e); } // Record our work. if ($this->bakeRecord) { $this->bakeRecord->addPageEntry($page, $didBake ? $this : null); } return $didBake; }
/** * Bakes the given page. Additional template data can be provided, along with * a specific set of posts for the pagination data. */ public function bake(IPage $page, array $extraData = null) { $didBake = false; try { $this->bakedFiles = array(); $this->paginationDataAccessed = false; $pageRenderer = new PageRenderer($page); $hasMorePages = true; while ($hasMorePages) { $didBake |= $this->bakeSinglePage($pageRenderer, $extraData); $data = $page->getPageData(); if ($data and isset($data['pagination'])) { $paginator = $data['pagination']; $hasMorePages = ($paginator->wasPaginationDataAccessed() and $paginator->hasMorePages()); if ($hasMorePages) { $page->setPageNumber($page->getPageNumber() + 1); // setPageNumber() resets the page's data, so when we // enter bakeSinglePage again in the next loop, we have // to re-set the extraData and all other stuff. } } } } catch (Exception $e) { throw new PieCrustException("Error baking page '{$page->getUri()}' (p{$page->getPageNumber()}): {$e->getMessage()}", 0, $e); } return $didBake; }