Project

General

Profile

Actions

Feature #93789

open

Provide a reliable method to determine page id in the Backend mode

Added by Dmitry Dulepov about 3 years ago. Updated about 1 year ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Backend API
Start date:
2021-03-21
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
medium
Sprint Focus:

Description

Currently there is no public API to get the current page id in the Backend mode. Such API can be useful for hooks that behave differently depending on where they are executed in the page tree. For example, we have a part of the tree where certain operations are restricted additionally to the TYPO3 permissions and we have other parts of the tree where only certain records are allowed, or yet other parts of the tree where we automatically move records to proper places if the editor accidentally creates them in a wrong folder.

Unfortunately the only current solution provided by TYPO3 is a condition that we could use in Page TSConfig but that condition does not work reliably because the implementation there is incomplete. Also we really need to get current page id there, not just whether we are in some part of tree or not. TYPO3 does not provide such public API, so we had to develop our own.

The current TYPO3 code for determining page id is located at EXT:backend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php but it is private and does not cover all possible cases.

The idea is to implement a new method in the BackendUtility with the following signature:

/**
 * Determines the current page id while in the Backend context. Behavior
 * in the Frontend context is undefined.
 *
 * @return int Page id or zero if it cannot be determined
 */
public static function getCurrentPageId(): int
{
}
Actions

Also available in: Atom PDF