PageDescendantsRepository

final readonly class \TYPO3\CMS\Core\Domain\Repository\PageDescendantsRepository

Fetches the descendants of pages - their subpages, the subpages of these and so on - with one recursive common table expression (CTE).

Only pages of the default language are part of the page tree. Pages are resolved for the given workspace: a page with a workspace version is found at the position of its version, pages new in the workspace are included, and pages deleted in the workspace are left out together with their subpages, unless they are requested.

Access restrictions are not applied by default, callers hand them in as constraints: a page not matching them is left out together with its subpages.

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Constants

MAX_TRAVERSAL_LEVELS  : int = 100

Methods

__construct()  : mixed
findDescendants()  : array<int, array<string, mixed>>
Returns the descendants of the given pages, without the given pages themselves, ordered depth-first: each page is followed by its subpages, pages with the same parent page are ordered by their "sorting" value.

Constants

MAX_TRAVERSAL_LEVELS

public int MAX_TRAVERSAL_LEVELS = 100

Methods

findDescendants()

Returns the descendants of the given pages, without the given pages themselves, ordered depth-first: each page is followed by its subpages, pages with the same parent page are ordered by their "sorting" value.

public findDescendants(array<int, int> $pageIds, int $depth, int $workspaceId[, callable(ExpressionBuilder, string): string|null $liveConstraint = null ][, array<int, QueryRestrictionInterface> $restrictions = [] ][, array<int, string> $fields = [] ][, bool $includeDeleted = false ][, bool $includeDeletedInWorkspace = false ]) : array<int, array<string, mixed>>

Each row holds the uid of the live page as "uid", the parent page uid (in the workspace) as "pid", "sorting" and the level below the given pages as "_LEVEL", starting with 1. A page with a workspace version additionally holds the uid of the version as "_ORIG_uid", other requested fields are then taken from the version.

Parameters

$pageIds : array<int, int>

Pages to start from, their descendants are returned in this order

$depth : int

Number of levels below the given pages, 1 for their direct subpages only

$workspaceId : int
$liveConstraint : callable(ExpressionBuilder, string): string|null = null

SQL constraint evaluated on the live page, receiving the table alias of the live page ("pages"), e.g. for the page permissions, which are not versioned. Column names may be unqualified or qualified with "pages"

$restrictions : array<int, QueryRestrictionInterface> = []

Restrictions evaluated on the page (the workspace version, if there is one), e.g. to leave out hidden pages

$fields : array<int, string> = []

Additional fields of the page records to return, '*' for all

$includeDeleted : bool = false

Whether deleted pages and their subpages are included

$includeDeletedInWorkspace : bool = false

Whether pages deleted in the workspace and their subpages are included

Return values

array<int, array<string, mixed>>
On this page