[FEATURE] Add Contexts for storing data access modes 04/57104/21
authorBenni Mack <benni@typo3.org>
Thu, 21 Jun 2018 20:23:58 +0000 (22:23 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 27 Jun 2018 11:27:05 +0000 (13:27 +0200)
commit5f8f50a0287dfba5b8c685420a825933bbe33313
tree37c3798b6f315bdfa6c63a6e67dd8fb51263119b
parente139c972833b888c3a8b2bca0b9c56301c84205b
[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 <no-reply@typo3.com>
Reviewed-by: Stefan Bürk <stefan.buerk@pure-metal.de>
Tested-by: Stefan Bürk <stefan.buerk@pure-metal.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
52 files changed:
typo3/sysext/adminpanel/Classes/Modules/InfoModule.php
typo3/sysext/adminpanel/Classes/Modules/PreviewModule.php
typo3/sysext/backend/Classes/Http/Application.php
typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php
typo3/sysext/core/Classes/Console/CommandApplication.php
typo3/sysext/core/Classes/Context/AspectInterface.php [new file with mode: 0644]
typo3/sysext/core/Classes/Context/Context.php [new file with mode: 0644]
typo3/sysext/core/Classes/Context/DateTimeAspect.php [new file with mode: 0644]
typo3/sysext/core/Classes/Context/Exception/AspectNotFoundException.php [new file with mode: 0644]
typo3/sysext/core/Classes/Context/Exception/AspectPropertyNotFoundException.php [new file with mode: 0644]
typo3/sysext/core/Classes/Context/UserAspect.php [new file with mode: 0644]
typo3/sysext/core/Classes/Context/VisibilityAspect.php [new file with mode: 0644]
typo3/sysext/core/Classes/Context/WorkspaceAspect.php [new file with mode: 0644]
typo3/sysext/core/Classes/Database/Query/Restriction/FrontendGroupRestriction.php
typo3/sysext/core/Classes/Database/Query/Restriction/FrontendRestrictionContainer.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85389-VariousPublicPropertiesInFavorOfContextAPI.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Feature-85389-ContextAPIForConsistentDataHandling.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Context/ContextTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Context/DateTimeAspectTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Context/UserAspectTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Context/VisibilityAspectTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Context/WorkspaceAspectTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendRestrictionContainerTest.php
typo3/sysext/core/Tests/Unit/Utility/RootlineUtilityTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbBackendTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php
typo3/sysext/extbase/Tests/Unit/Service/ExtensionServiceTest.php
typo3/sysext/felogin/Classes/Controller/FrontendLoginController.php
typo3/sysext/felogin/Tests/Unit/Controller/FrontendLoginControllerTest.php
typo3/sysext/fluid/Classes/ViewHelpers/Security/IfAuthenticatedViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Security/IfAuthenticatedViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Security/IfHasRoleViewHelperTest.php
typo3/sysext/frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Http/Application.php
typo3/sysext/frontend/Classes/Middleware/BackendUserAuthenticator.php
typo3/sysext/frontend/Classes/Middleware/FrontendUserAuthenticator.php
typo3/sysext/frontend/Classes/Middleware/PageResolver.php
typo3/sysext/frontend/Classes/Page/PageRepository.php
typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php
typo3/sysext/frontend/Tests/Functional/Controller/TypoScriptFrontendControllerTest.php
typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php
typo3/sysext/frontend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php
typo3/sysext/indexed_search/Classes/Domain/Repository/IndexSearchRepository.php
typo3/sysext/indexed_search/Classes/Indexer.php
typo3/sysext/install/Classes/Http/Application.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/PropertyPublicMatcher.php
typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php