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>
- $additionalWhereClause : string|null
- $currentWorkspace : int
- The workspace ID to operate on
- $eventDispatcher : EventDispatcherInterface
- $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.
- $quotedFields : array<string|int, 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)
Methods
- __construct() : mixed
- fetchFilteredTree() : array<string|int, mixed>
- Retrieve the page tree based on the given search filter
- getFlattenedPages() : array<string|int, mixed>
- 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.
- 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
- 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<string|int, mixed>
- Fetch all non-deleted pages, regardless of permissions (however, considers additionalQueryRestrictions and additionalWhereClause).
- 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 read-only
protected
array<string|int, mixed>
$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
array<string|int, string>
$fields
$fullPageTree
Full page tree when selected without permissions applied.
protected
array<string|int, mixed>
$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
array<string|int, string>
$quotedFields
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>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(array<string|int, int> $entryPointIds, int $depth) : array<string|int, mixed>
Parameters
- $entryPointIds : array<string|int, int>
- $depth : int
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 = [] ]) : 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> = []
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
boolsetAdditionalWhereClause()
public
setAdditionalWhereClause(string $additionalWhereClause) : void
Parameters
- $additionalWhereClause : string
addChildrenToPage()
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) : void
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) : void
Parameters
- $tree : array<string|int, mixed>
- $callback : callable
fetchAllPages()
Fetch all non-deleted pages, regardless of permissions (however, considers additionalQueryRestrictions and additionalWhereClause).
protected
fetchAllPages(array<string|int, mixed> $dbMounts) : array<string|int, mixed>
That's why it's internal.
Parameters
- $dbMounts : array<string|int, mixed>
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> = []