OtPageRepository.php 870 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Opentalent\OtTemplating\Page;
  3. use TYPO3\CMS\Frontend\Page\PageRepository;
  4. class OtPageRepository extends PageRepository
  5. {
  6. /**
  7. * Recursively returns all the subpages of the given page
  8. *
  9. * @param $pageId
  10. * @param string $fields
  11. * @param string $sortField
  12. * @param string $additionalWhereClause
  13. * @param bool $checkShortcuts
  14. * @return array
  15. */
  16. public function getAllSubpagesForPage($pageId) {
  17. $subpages = [];
  18. $stack = $this->getSubpagesForPages([$pageId], '*', 'sorting', '', false);
  19. foreach ($stack as $page) {
  20. $subpages[] = $page;
  21. $children = $this->getAllSubpagesForPage($page['uid']);
  22. if (!empty($children)) {
  23. $subpages = array_merge($subpages, $children);
  24. }
  25. }
  26. return $subpages;
  27. }
  28. }