Project

General

Profile

Actions

Task #97638

closed

Use local TypoScriptFrontendController instead of $GLOBALS['TSFE'] in ContentObjects

Added by Markus Friedrich over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
Start date:
2022-05-16
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

The ContentObjectRenderer already offers the possibility to use a local version of the TypoScriptFrontendController, if this is not available the global version is used.

So the base is there to use different initialized frontend environments without risking conflicts, but unfortunately most ContentObjects still access the global version $GLOBALS['TSFE'] directly, e.g. the ImageResourceContentObject:

    public function render($conf = [])
    {
        $GLOBALS['TSFE']->lastImgResourceInfo = $this->cObj->getImgResource($conf['file'] ?? '', $conf['file.'] ?? []);
        if ($GLOBALS['TSFE']->lastImgResourceInfo) {
            $imageResource = $GLOBALS['TSFE']->lastImgResourceInfo[3];
            $theValue = isset($conf['stdWrap.']) ? $this->cObj->stdWrap($imageResource, $conf['stdWrap.']) : $imageResource;
        } else {
            $theValue = '';
        }

        return $theValue;
    }

From my point of view it makes sense in general to rely less on global objects, but with the indexing of EXT:solr there are also concrete use cases in which consistent access to the local objects is helpful.

Since the ContentObjectRenderer itself falls back on the global object of the TypoScriptFrontendController, an adaption of the ContentObjects should be uncomplicated and should not result in a breaking change:

    /**
     * @return TypoScriptFrontendController|null
     * @internal this is set to public so extensions such as EXT:solr can use the method in tests.
     */
    public function getTypoScriptFrontendController()
    {
        return $this->typoScriptFrontendController ?: $GLOBALS['TSFE'] ?? null;
    }
(TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer)

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #98622: Pass down local TypoScriptFrontendController when instantiating a new ContentObjectRenderer from RECORDS and CONTENTClosed2022-10-14

Actions
Actions #1

Updated by Markus Friedrich over 2 years ago

We will try to provide a PR in the next few days, would be nice if the changes could be merged into one of next versions of TYPO3 11.

Actions #2

Updated by Gerrit Code Review over 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #3

Updated by Gerrit Code Review over 2 years ago

Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74682

Actions #4

Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #5

Updated by Gerrit Code Review over 2 years ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #6

Updated by Gerrit Code Review over 2 years ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #7

Updated by Gerrit Code Review over 2 years ago

Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #8

Updated by Gerrit Code Review over 2 years ago

Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #9

Updated by Gerrit Code Review over 2 years ago

Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #10

Updated by Gerrit Code Review over 2 years ago

Patch set 8 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #11

Updated by Gerrit Code Review over 2 years ago

Patch set 9 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #12

Updated by Gerrit Code Review over 2 years ago

Patch set 10 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #13

Updated by Gerrit Code Review over 2 years ago

Patch set 11 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #14

Updated by Gerrit Code Review over 2 years ago

Patch set 12 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #15

Updated by Gerrit Code Review over 2 years ago

Patch set 13 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #16

Updated by Gerrit Code Review over 2 years ago

Patch set 14 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #17

Updated by Gerrit Code Review over 2 years ago

Patch set 15 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #18

Updated by Gerrit Code Review over 2 years ago

Patch set 16 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/74681

Actions #19

Updated by Markus Friedrich over 2 years ago

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

Updated by Gerrit Code Review over 2 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #21

Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #22

Updated by Gerrit Code Review over 2 years ago

Patch set 3 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #23

Updated by Gerrit Code Review over 2 years ago

Patch set 4 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #24

Updated by Gerrit Code Review over 2 years ago

Patch set 5 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #25

Updated by Gerrit Code Review over 2 years ago

Patch set 6 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #26

Updated by Gerrit Code Review over 2 years ago

Patch set 7 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #27

Updated by Gerrit Code Review over 2 years ago

Patch set 8 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #28

Updated by Gerrit Code Review over 2 years ago

Patch set 9 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #29

Updated by Gerrit Code Review over 2 years ago

Patch set 10 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #30

Updated by Gerrit Code Review over 2 years ago

Patch set 11 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #31

Updated by Gerrit Code Review over 2 years ago

Patch set 12 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #32

Updated by Gerrit Code Review over 2 years ago

Patch set 13 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #33

Updated by Gerrit Code Review over 2 years ago

Patch set 14 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #34

Updated by Gerrit Code Review over 2 years ago

Patch set 15 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75073

Actions #35

Updated by Markus Friedrich over 2 years ago

  • Status changed from Under Review to Resolved
Actions #36

Updated by Benni Mack about 2 years ago

  • Status changed from Resolved to Closed
Actions #37

Updated by Andreas Kießling about 2 years ago

  • Related to Bug #98622: Pass down local TypoScriptFrontendController when instantiating a new ContentObjectRenderer from RECORDS and CONTENT added
Actions

Also available in: Atom PDF