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.
this class is not public API yet, as it needs to be proven stable enough first.
Table of Contents
Properties
- $additionalQueryRestrictions : array<string|int, mixed>
- $currentWorkspace : int
- The workspace ID to operate on
- $fields : array<string|int, string>
- Fields to be queried from the database
- $fullPageTree : array<string|int, mixed>
- Full page tree when selected without permissions applied.
Methods
- __construct() : mixed
- fetchFilteredTree() : array<string|int, mixed>
- Retrieve the page tree based on the given search filter
- getTree() : array<string|int, mixed>
- Main entry point for this repository, to fetch the tree data for a page.
- getTreeLevels() : array<string|int, mixed>
- 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<string|int, mixed>
- Fetch all non-deleted pages, regardless of permissions. That's why it's internal.
- filterPagesOnMountPoints() : array<string|int, mixed>
- Filter all records outside of the allowed mount points
- findInPageTree() : array<string|int, mixed>
- Looking for a page by traversing the tree
- getBackendUser() : BackendUserAuthentication
- getChildPageRecords() : array<string|int, mixed>
- getPageRecords() : array<string|int, mixed>
- Retrieve the page records based on the given page or parent page ids
- groupAndSortPages() : array<string|int, mixed>
- Group pages by parent page and sort pages based on sorting property
Properties
$additionalQueryRestrictions
protected
array<string|int, mixed>
$additionalQueryRestrictions
= []
$currentWorkspace
The workspace ID to operate on
protected
int
$currentWorkspace
= 0
$fields
Fields to be queried from the database
protected
array<string|int, string>
$fields
= ['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<string|int, mixed>
$fullPageTree
= []
Methods
__construct()
public
__construct([int $workspaceId = 0 ][, array<string|int, mixed> $additionalFieldsToQuery = [] ][, array<string|int, mixed> $additionalQueryRestrictions = [] ]) : mixed
Parameters
- $workspaceId : int = 0
-
the workspace ID to be checked for.
- $additionalFieldsToQuery : array<string|int, mixed> = []
-
an array with more fields that should be accessed.
- $additionalQueryRestrictions : array<string|int, mixed> = []
-
an array with more restrictions to add
fetchFilteredTree()
Retrieve the page tree based on the given search filter
public
fetchFilteredTree(string $searchFilter, array<string|int, mixed> $allowedMountPointPageIds, string $additionalWhereClause) : array<string|int, mixed>
Parameters
- $searchFilter : string
- $allowedMountPointPageIds : array<string|int, mixed>
- $additionalWhereClause : string
Return values
array<string|int, mixed>getTree()
Main entry point for this repository, to fetch the tree data for a page.
public
getTree(int $entryPoint[, callable|null $callback = null ][, array<string|int, mixed> $dbMounts = [] ][, bool $resolveUserPermissions = false ]) : array<string|int, mixed>
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<string|int, mixed> = []
- $resolveUserPermissions : bool = false
Return values
array<string|int, mixed>getTreeLevels()
Get the page tree based on a given page record and a given depth
public
getTreeLevels(array<string|int, mixed> $pageTree, int $depth[, array<string|int, mixed>|null $entryPointIds = null ]) : array<string|int, mixed>
Parameters
- $pageTree : array<string|int, mixed>
-
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<string|int, mixed>|null = null
-
entryPointIds to include (null in case no entry-points were provided)
Return values
array<string|int, mixed> —An array with page records and their children
hasChildren()
public
hasChildren(int $pid) : bool
Parameters
- $pid : int
Return values
booladdChildrenToPage()
Adds the property "_children" to a page record with the child pages
protected
addChildrenToPage(array<string|int, mixed> &$page, array<string|int, array<string|int, mixed>> &$groupedAndSortedPagesByPid) : mixed
Parameters
- $page : array<string|int, mixed>
- $groupedAndSortedPagesByPid : array<string|int, array<string|int, mixed>>
applyCallbackToChildren()
Removes items from a tree based on a callback, usually used for permission checks
protected
applyCallbackToChildren(array<string|int, mixed> &$tree, callable $callback) : mixed
Parameters
- $tree : array<string|int, mixed>
- $callback : callable
fetchAllPages()
Fetch all non-deleted pages, regardless of permissions. That's why it's internal.
protected
fetchAllPages(array<string|int, mixed> $dbMounts[, bool $resolveUserPermissions = false ]) : array<string|int, mixed>
Parameters
- $dbMounts : array<string|int, mixed>
- $resolveUserPermissions : bool = false
Return values
array<string|int, mixed> —the full page tree of the whole installation
filterPagesOnMountPoints()
Filter all records outside of the allowed mount points
protected
filterPagesOnMountPoints(array<string|int, mixed> $pages, array<string|int, mixed> $mountPoints) : array<string|int, mixed>
Parameters
- $pages : array<string|int, mixed>
- $mountPoints : array<string|int, mixed>
Return values
array<string|int, mixed>findInPageTree()
Looking for a page by traversing the tree
protected
findInPageTree(int $pageId, array<string|int, mixed> $pages) : array<string|int, mixed>
Parameters
- $pageId : int
-
the page ID to search for
- $pages : array<string|int, mixed>
-
the page tree to look for the page
Return values
array<string|int, mixed> —Array of the tree data, empty array if nothing was found
getBackendUser()
protected
getBackendUser() : BackendUserAuthentication
Return values
BackendUserAuthenticationgetChildPageRecords()
protected
getChildPageRecords(array<string|int, mixed> $parentPageIds) : array<string|int, mixed>
Parameters
- $parentPageIds : array<string|int, mixed>
Return values
array<string|int, mixed>getPageRecords()
Retrieve the page records based on the given page or parent page ids
protected
getPageRecords([array<string|int, mixed> $pageIds = [] ][, array<string|int, mixed> $parentPageIds = [] ]) : array<string|int, mixed>
Parameters
- $pageIds : array<string|int, mixed> = []
- $parentPageIds : array<string|int, mixed> = []
Return values
array<string|int, mixed>groupAndSortPages()
Group pages by parent page and sort pages based on sorting property
protected
groupAndSortPages(array<string|int, mixed> $pages[, array<string|int, mixed> $groupedAndSortedPagesByPid = [] ]) : array<string|int, mixed>
Parameters
- $pages : array<string|int, mixed>
- $groupedAndSortedPagesByPid : array<string|int, mixed> = []