• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FluidTYPO3 / flux / 13132978785

04 Feb 2025 10:05AM UTC coverage: 93.26% (+0.01%) from 93.249%
13132978785

Pull #2229

github

web-flow
Merge 798b7f84e into 254a8939b
Pull Request #2229: [BUGFIX] Always fetch ContentObject from request in TYPO3v12+

3 of 3 new or added lines in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

7071 of 7582 relevant lines covered (93.26%)

66.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/Classes/Utility/ContentObjectFetcher.php
1
<?php
2
namespace FluidTYPO3\Flux\Utility;
3

4
/*
5
 * This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10

11
use Psr\Http\Message\ServerRequestInterface;
12
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
13
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
14
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
15
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
16

17
class ContentObjectFetcher
18
{
19
    public static function resolve(?ConfigurationManagerInterface $configurationManager = null): ?ContentObjectRenderer
20
    {
21
        $contentObject = null;
14✔
22
        $request = $configurationManager !== null && method_exists($configurationManager, 'getRequest')
14✔
UNCOV
23
            ? $configurationManager->getRequest()
×
24
            : ($GLOBALS['TYPO3_REQUEST'] ?? null);
14✔
25

26
        if ($request && ($configurationManager === null || version_compare(VersionNumberUtility::getCurrentTypo3Version(), '12.0', '>='))) {
14✔
27
            $contentObject = static::resolveFromRequest($request);
6✔
28
        }
29

30
        if ($contentObject === null && $configurationManager !== null && method_exists($configurationManager, 'getContentObject')) {
14✔
31
            $contentObject = $configurationManager->getContentObject();
12✔
32
        }
33

34
        return $contentObject;
14✔
35
    }
36

37
    protected static function resolveFromRequest(ServerRequestInterface $request): ?ContentObjectRenderer
38
    {
39
        /** @var TypoScriptFrontendController $controller */
40
        $controller = $request->getAttribute('frontend.controller');
6✔
41
        return $controller instanceof TypoScriptFrontendController ? $controller->cObj : null;
6✔
42
    }
43
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc