Feature #85389

Introduce Context API for consistent data handling

Added by Benni Mack about 1 year ago. Updated 10 months ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Content Rendering
Target version:
Start date:
2018-06-26
Due date:
% Done:

100%

PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

A new API for containing current information about various settings is added - Contexts.

The current context contains various (flexible) aspects, which act as a data bag.

An aspect is typically exposing only the necessary parts, e.g. not a full frontend user object, but only the data that is needed for various checks.

In practice, the Context API replaces a lot of inconsistent settings spread over all globally available objects (TSFE, sys_page, BE_USER) and makes them available at any time of the application / request lifecycle.

Any extension can add an aspect to the current context.


Related issues

Related to TYPO3 Core - Task #85408: Minor cleanups for Context API Closed 2018-06-27
Related to TYPO3 Core - Bug #85447: Adapt glitches of context patch Closed 2018-07-02

Associated revisions

Revision 5f8f50a0 (diff)
Added by Benni Mack about 1 year ago

[FEATURE] Add Contexts for storing data access modes

A new "Context" concept is added which allows to keep
the state of common TYPO3 Request Data in form of
so-called Aspects.

An aspect contains properties which can be fetched,
but only the ones that are really necessary, instead of
exposing a full object (e.g. BE_USER).

The main goal is to centralize some global variables
distributed in various places.

In the first step the following variables are considered:

- $TSFE->showHiddenPages
- $TSFE->showHiddenRecords
- $TSFE->beUserLogin
- $TSFE->gr_list
- $TSFE->loginUser
- $GLOBALS[SIM_EXEC_TIME]
- $GLOBALS['BE_USER']->workspace

For now the Context is a singleton object, but should
be fetched from a DI container.

Sometimes a custom context is necessary, so it is
cloned (see usage in TSFE).

The difference to the PSR-7 request attributes is that the
context is ONLY related to data access (like permissions / visibility)
and also independent if TYPO3 is running via HTTP or CLI
(thus, can be used in CLI mode as well).

Next Steps:
- Migrate PageRepository->versioningWorkspaceId
- Migrate TSFE->simUserGroup
- Use DateTimeAspect everywhere
- Introduce Language + Page Aspects
- Introduce the context object into ContentObjectRenderer and cObjects
- Use Contexts in RestrictionContainers
- Use Contexts in TYPO3 Backend
- Decouple sys_page behaviour from TSFE where applicable
- Ensure TypoScript conditions continue to work / have a documented alternative

Resolves: #85389
Releases: master
Change-Id: I9e27e581a1632fcd8c3c6a9e0954b76b91f42c52
Reviewed-on: https://review.typo3.org/57104
Tested-by: TYPO3com <>
Reviewed-by: Stefan Bürk <>
Tested-by: Stefan Bürk <>
Reviewed-by: Susanne Moog <>
Tested-by: Susanne Moog <>
Reviewed-by: Andreas Fernandez <>
Tested-by: Andreas Fernandez <>

Revision ed0e14b2 (diff)
Added by Benni Mack about 1 year ago

[BUGFIX] Fix regressions and leftovers in Context API

Some usages where now-deprecated properties are used,
have been adjusted.

The RST file has been enhanced to clarify when to clone
the context, and when to override an aspect.

Additionally, the usage within TemplateService has been
optimized to also receive an optional context object,
similar to the initial patch's PageRepository approach.

Resolves: #85408
Related: #85389
Releases: master
Change-Id: I178ff07cbfe999a90bf7d5dd4f20a6170876d003
Reviewed-on: https://review.typo3.org/57396
Tested-by: TYPO3com <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>
Reviewed-by: Wouter Wolters <>
Tested-by: Wouter Wolters <>

Revision bf5e298a (diff)
Added by Christian Kuhn about 1 year ago

[BUGFIX] Adapt glitches of context patch

Some type hinting related and test changes from the main
context patch are fixed with the patch.

Resolves: #85447
Related: #85389
Releases: master
Change-Id: I674fd1cc253929643361a71ad7c5084d4429ddc5
Reviewed-on: https://review.typo3.org/57436
Reviewed-by: Mathias Brodala <>
Tested-by: TYPO3com <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>
Tested-by: Anja Leichsenring <>
Reviewed-by: Anja Leichsenring <>

History

#1 Updated by Gerrit Code Review about 1 year ago

  • Status changed from New to Under Review

Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57104

#2 Updated by Gerrit Code Review about 1 year ago

Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57104

#3 Updated by Gerrit Code Review about 1 year ago

Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57104

#4 Updated by Gerrit Code Review about 1 year ago

Patch set 20 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/57104

#5 Updated by Benni Mack about 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#6 Updated by Christian Kuhn about 1 year ago

  • Related to Task #85408: Minor cleanups for Context API added

#7 Updated by Christian Kuhn about 1 year ago

  • Related to Bug #85447: Adapt glitches of context patch added

#8 Updated by Benni Mack 10 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF