‪TYPO3CMS  ‪main
TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository Class Reference

Public Member Functions

 __construct (int $workspaceId=0, array $additionalFieldsToQuery=[], array $additionalQueryRestrictions=[])
 
 setAdditionalWhereClause (string $additionalWhereClause)
 
 getTree (int $entryPoint, callable $callback=null, array $dbMounts=[])
 
array getTreeLevels (array $pageTree, int $depth, array $entryPointIds=[])
 
 getFlattenedPages (array $entryPointIds, int $depth)
 
 hasChildren (int $pid)
 
 fetchFilteredTree (string $searchFilter, array $allowedMountPointPageIds, string $additionalWhereClause)
 

Protected Member Functions

 applyCallbackToChildren (array &$tree, callable $callback)
 
 getChildPageRecords (array $parentPageIds)
 
 getPageRecords (array $pageIds=[], array $parentPageIds=[])
 
array fetchAllPages (array $dbMounts)
 
 addChildrenToPage (array &$page, array &$groupedAndSortedPagesByPid)
 
array findInPageTree (int $pageId, array $pages)
 
 filterPagesOnMountPoints (array $pages, array $mountPoints)
 
 groupAndSortPages (array $pages, array $groupedAndSortedPagesByPid=[])
 
 getBackendUser ()
 

Protected Attributes

readonly array $fields
 
readonly array $quotedFields
 
readonly int $currentWorkspace
 
array $fullPageTree = []
 
readonly array $additionalQueryRestrictions
 
string $additionalWhereClause = null
 

Detailed Description

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.

Definition at line 39 of file PageTreeRepository.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::__construct ( int  $workspaceId = 0,
array  $additionalFieldsToQuery = [],
array  $additionalQueryRestrictions = [] 
)
Parameters
int$workspaceId‪the workspace ID to be checked for.
array$additionalFieldsToQuery‪an array with more fields that should be accessed.
array$additionalQueryRestrictions‪an array with more restrictions to add

Definition at line 74 of file PageTreeRepository.php.

References TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\$additionalQueryRestrictions.

Member Function Documentation

◆ addChildrenToPage()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::addChildrenToPage ( array &  $page,
array &  $groupedAndSortedPagesByPid 
)
protected

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

Parameters
array[]$groupedAndSortedPagesByPid

Definition at line 476 of file PageTreeRepository.php.

Referenced by TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\fetchAllPages(), TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\fetchFilteredTree(), and TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getTreeLevels().

◆ applyCallbackToChildren()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::applyCallbackToChildren ( array &  $tree,
callable  $callback 
)
protected

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

Definition at line 150 of file PageTreeRepository.php.

Referenced by TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getTree().

◆ fetchAllPages()

array TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::fetchAllPages ( array  $dbMounts)
protected

Fetch all non-deleted pages, regardless of permissions (however, considers additionalQueryRestrictions and additionalWhereClause). That's why it's internal.

Returns
‪array the full page tree of the whole installation

Definition at line 350 of file PageTreeRepository.php.

References TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\$fullPageTree, $GLOBALS, TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\addChildrenToPage(), TYPO3\CMS\Core\Database\Connection\PARAM_INT, and TYPO3\CMS\Core\Database\Query\QueryHelper\stripLogicalOperatorPrefix().

Referenced by TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getTree().

◆ fetchFilteredTree()

◆ filterPagesOnMountPoints()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::filterPagesOnMountPoints ( array  $pages,
array  $mountPoints 
)
protected

Filter all records outside of the allowed mount points

Definition at line 671 of file PageTreeRepository.php.

References TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getBackendUser().

Referenced by TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\fetchFilteredTree().

◆ findInPageTree()

array TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::findInPageTree ( int  $pageId,
array  $pages 
)
protected

Looking for a page by traversing the tree

Parameters
int$pageId‪the page ID to search for
array$pages‪the page tree to look for the page
Returns
‪array Array of the tree data, empty array if nothing was found

Definition at line 492 of file PageTreeRepository.php.

Referenced by TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getTree().

◆ getBackendUser()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::getBackendUser ( )
protected

◆ getChildPageRecords()

◆ getFlattenedPages()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::getFlattenedPages ( array  $entryPointIds,
int  $depth 
)

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.

Parameters
int[]$entryPointIds

Definition at line 204 of file PageTreeRepository.php.

References TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getChildPageRecords(), and TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getPageRecords().

◆ getPageRecords()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::getPageRecords ( array  $pageIds = [],
array  $parentPageIds = [] 
)
protected

◆ getTree()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::getTree ( int  $entryPoint,
callable  $callback = null,
array  $dbMounts = [] 
)

Main entry point for this repository, to fetch the tree data for a page. Basically the page record, plus all child pages and their child pages recursively, stored within "_children" item.

Parameters
int$entryPoint‪the page ID to fetch the tree for
callable | null$callback‪a callback to be used to check for permissions and filter out pages not to be included.

Definition at line 130 of file PageTreeRepository.php.

References TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\$fullPageTree, TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\applyCallbackToChildren(), TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\fetchAllPages(), and TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\findInPageTree().

◆ getTreeLevels()

array TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::getTreeLevels ( array  $pageTree,
int  $depth,
array  $entryPointIds = [] 
)

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

Parameters
array$pageTree‪The page record of the top level page you want to get the page tree of
int$depth‪Number of levels to fetch
array$entryPointIds‪entryPointIds to include
Returns
‪array An array with page records and their children

Definition at line 172 of file PageTreeRepository.php.

References TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\addChildrenToPage(), TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getChildPageRecords(), TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getPageRecords(), and TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\groupAndSortPages().

◆ groupAndSortPages()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::groupAndSortPages ( array  $pages,
array  $groupedAndSortedPagesByPid = [] 
)
protected

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

Parameters
array$groupedAndSortedPagesByPid

Definition at line 743 of file PageTreeRepository.php.

Referenced by TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\fetchFilteredTree(), and TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository\getTreeLevels().

◆ hasChildren()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::hasChildren ( int  $pid)

◆ setAdditionalWhereClause()

TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::setAdditionalWhereClause ( string  $additionalWhereClause)

Member Data Documentation

◆ $additionalQueryRestrictions

readonly array TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::$additionalQueryRestrictions
protected

◆ $additionalWhereClause

string TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::$additionalWhereClause = null
protected

◆ $currentWorkspace

readonly int TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::$currentWorkspace
protected

The workspace ID to operate on

Definition at line 58 of file PageTreeRepository.php.

◆ $fields

readonly array TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::$fields
protected

Definition at line 46 of file PageTreeRepository.php.

◆ $fullPageTree

array TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::$fullPageTree = []
protected

◆ $quotedFields

readonly array TYPO3\CMS\Backend\Tree\Repository\PageTreeRepository::$quotedFields
protected

Definition at line 53 of file PageTreeRepository.php.