PageTreeRepository

class \TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository

Fetches ALL pages in the page tree, possibly overlaid with the workspace in a sorted way.

This works agnostic of the Backend User, allows to be used in FE as well in the future.

Table of Contents

Properties

$additionalQueryRestrictions  : array
$additionalWhereClause  : string|null
$currentWorkspace  : int
The workspace ID to operate on
$eventDispatcher  : EventDispatcherInterface
$fields  : string[]
Fields to be queried from the database
$fullPageTree  : array
Full page tree when selected without permissions applied.
$quotedFields  : string[]
The fields array, quoted for repeated use in recursive pages queries, to avoid the need to newly quote the fields for each single query (which can get really expensive for a large amount of fields)
$runtimeCache  : FrontendInterface

Methods

__construct()  : mixed
fetchFilteredTree()  : array
Retrieve the page tree based on the given search filter
getFlattenedPages()  : array
Useful to get a list of pages, with a specific depth, e.g. to limit a query to another table to a list of page IDs.
getTranslationMatches()  : int[]
Get translation language UIDs that matched for a specific page UID
getTree()  : array
Main entry point for this repository, to fetch the tree data for a page.
getTreeLevels()  : array
Get the page tree based on a given page record and a given depth
hasChildren()  : bool
setAdditionalWhereClause()  : void
addChildrenToPage()  : void
Adds the property "_children" to a page record with the child pages
applyCallbackToChildren()  : void
Removes items from a tree based on a callback, usually used for permission checks
fetchAllPages()  : array
Fetch all non-deleted pages, regardless of permissions (however, considers additionalQueryRestrictions and additionalWhereClause).
filterPagesOnMountPoints()  : array
Filter all records outside of the allowed mount points
findInPageTree()  : array
Looking for a page by traversing the tree
getBackendUser()  : BackendUserAuthentication
getChildPageRecords()  : array
getPageRecords()  : array
Retrieve the page records based on the given page or parent page ids
groupAndSortPages()  : array
Group pages by parent page and sort pages based on sorting property

Properties

$additionalQueryRestrictions read-only

protected array $additionalQueryRestrictions

$additionalWhereClause

protected string|null $additionalWhereClause = null

$currentWorkspace read-only

The workspace ID to operate on

protected int $currentWorkspace

$eventDispatcher

protected EventDispatcherInterface $eventDispatcher

$fields read-only

Fields to be queried from the database

protected string[] $fields

$fullPageTree

Full page tree when selected without permissions applied.

protected array $fullPageTree = []

$quotedFields read-only

The fields array, quoted for repeated use in recursive pages queries, to avoid the need to newly quote the fields for each single query (which can get really expensive for a large amount of fields)

protected string[] $quotedFields

Methods

__construct()

public __construct([int $workspaceId = 0 ][, array $additionalFieldsToQuery = [] ][, array $additionalQueryRestrictions = [] ]) : mixed

Parameters

$workspaceId : int = 0

the workspace ID to be checked for.

$additionalFieldsToQuery : array = []

an array with more fields that should be accessed.

$additionalQueryRestrictions : array = []

an array with more restrictions to add

fetchFilteredTree()

Retrieve the page tree based on the given search filter

public fetchFilteredTree(string $searchFilter, array $allowedMountPointPageIds, string $additionalWhereClause) : array

Parameters

$searchFilter : string
$allowedMountPointPageIds : array
$additionalWhereClause : string

Return values

array

getFlattenedPages()

Useful to get a list of pages, with a specific depth, e.g. to limit a query to another table to a list of page IDs.

public getFlattenedPages(int[] $entryPointIds, int $depth) : array

Parameters

$entryPointIds : int[]
$depth : int

Return values

array

getTranslationMatches()

Get translation language UIDs that matched for a specific page UID

public getTranslationMatches(int $pageUid) : int[]

Parameters

$pageUid : int

Return values

int[]

getTree()

Main entry point for this repository, to fetch the tree data for a page.

public getTree(int $entryPoint[, callable|null $callback = null ][, array $dbMounts = [] ]) : array

Basically the page record, plus all child pages and their child pages recursively, stored within "_children" item.

Parameters

$entryPoint : int

the page ID to fetch the tree for

$callback : callable|null = null

a callback to be used to check for permissions and filter out pages not to be included.

$dbMounts : array = []

Return values

array

getTreeLevels()

Get the page tree based on a given page record and a given depth

public getTreeLevels(array $pageTree, int $depth[, array|null $entryPointIds = null ]) : array

Parameters

$pageTree : array

The page record of the top level page you want to get the page tree of

$depth : int

Number of levels to fetch

$entryPointIds : array|null = null

entryPointIds to include (null in case no entry-points were provided)

Return values

array —

An array with page records and their children

hasChildren()

public hasChildren(int $pid) : bool

Parameters

$pid : int

Return values

bool

setAdditionalWhereClause()

public setAdditionalWhereClause(string $additionalWhereClause) : void

Parameters

$additionalWhereClause : string

addChildrenToPage()

Adds the property "_children" to a page record with the child pages

protected addChildrenToPage(array &$page, array[] &$groupedAndSortedPagesByPid) : void

Parameters

$page : array
$groupedAndSortedPagesByPid : array[]

applyCallbackToChildren()

Removes items from a tree based on a callback, usually used for permission checks

protected applyCallbackToChildren(array &$tree, callable $callback) : void

Parameters

$tree : array
$callback : callable

fetchAllPages()

Fetch all non-deleted pages, regardless of permissions (however, considers additionalQueryRestrictions and additionalWhereClause).

protected fetchAllPages(array $dbMounts) : array

That's why it's internal.

Parameters

$dbMounts : array

Return values

array —

the full page tree of the whole installation

filterPagesOnMountPoints()

Filter all records outside of the allowed mount points

protected filterPagesOnMountPoints(array $pages, array $mountPoints) : array

Parameters

$pages : array
$mountPoints : array

Return values

array

findInPageTree()

Looking for a page by traversing the tree

protected findInPageTree(int $pageId, array $pages) : array

Parameters

$pageId : int

the page ID to search for

$pages : array

the page tree to look for the page

Return values

array —

Array of the tree data, empty array if nothing was found

getChildPageRecords()

protected getChildPageRecords(array $parentPageIds) : array

Parameters

$parentPageIds : array

Return values

array

getPageRecords()

Retrieve the page records based on the given page or parent page ids

protected getPageRecords([array $pageIds = [] ][, array $parentPageIds = [] ]) : array

Parameters

$pageIds : array = []
$parentPageIds : array = []

Return values

array

groupAndSortPages()

Group pages by parent page and sort pages based on sorting property

protected groupAndSortPages(array $pages[, array $groupedAndSortedPagesByPid = [] ]) : array

Parameters

$pages : array
$groupedAndSortedPagesByPid : array = []

Return values

array
On this page