private function generatePages(Document $originalDocument, $nbPages, $isFirstPagination = true, $collectionNb = 1) { $pages = array(); for ($pageNb = 1; $pageNb <= $nbPages; ++$pageNb) { $currentPage = $pages[$pageNb] = clone $originalDocument; if (1 == $pageNb) { continue; } $pathInfo = pathinfo($currentPage->getPath()); if ($isFirstPagination) { $pathInfo['filename'] = sprintf('%s-page-%d', $pathInfo['filename'], $pageNb); } else { $pathInfo['filename'] = sprintf('%s-%d-page-%d', $pathInfo['filename'], $collectionNb, $pageNb); } $currentPage->setPath(ltrim(sprintf('%s/%s.%s', $pathInfo['dirname'], $pathInfo['filename'], $pathInfo['extension']), './')); } return $pages; }