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
$currentWorkspace  : int
The workspace ID to operate on
$fields  : string[]
Fields to be queried from the database
$fullPageTree  : array
Full page tree when selected without permissions applied.

Methods

__construct()  : mixed
fetchFilteredTree()  : array
Retrieve the page tree based on the given search filter
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
addChildrenToPage()  : mixed
Adds the property "_children" to a page record with the child pages
applyCallbackToChildren()  : mixed
Removes items from a tree based on a callback, usually used for permission checks
fetchAllPages()  : array
Fetch all non-deleted pages, regardless of permissions. That's why it's internal.
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

protected array $additionalQueryRestrictions = []

$currentWorkspace

The workspace ID to operate on

protected int $currentWorkspace = 0

$fields

Fields to be queried from the database

protected string[] $fields = ['uid', 'pid', 'sorting', 'starttime', 'endtime', 'hidden', …
Show the full value['uid', 'pid', 'sorting', 'starttime', 'endtime', 'hidden', 'fe_group', 'title', 'nav_title', 'nav_hide', 'php_tree_stop', 'doktype', 'is_siteroot', 'module', 'extendToSubpages', 'content_from_pid', 't3ver_oid', 't3ver_wsid', 't3ver_state', 't3ver_stage', 'perms_userid', 'perms_user', 'perms_groupid', 'perms_group', 'perms_everybody', 'mount_pid', 'shortcut', 'shortcut_mode', 'mount_pid_ol', 'url', 'sys_language_uid', 'l10n_parent']

$fullPageTree

Full page tree when selected without permissions applied.

protected array $fullPageTree = []

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

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 = [] ][, bool $resolveUserPermissions = false ]) : 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 = []
$resolveUserPermissions : bool = false

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

addChildrenToPage()

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

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

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) : mixed

Parameters

$tree : array
$callback : callable

fetchAllPages()

Fetch all non-deleted pages, regardless of permissions. That's why it's internal.

protected fetchAllPages(array $dbMounts[, bool $resolveUserPermissions = false ]) : array

Parameters

$dbMounts : array
$resolveUserPermissions : bool = false

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