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

FluidTYPO3 / flux / 13133095136

04 Feb 2025 10:11AM UTC coverage: 93.264% (+0.02%) from 93.249%
13133095136

Pull #2229

github

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

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

1 existing line in 1 file now uncovered.

7075 of 7586 relevant lines covered (93.26%)

66.05 hits per line

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

93.33
/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
14✔
27
            && ($configurationManager === null
14✔
28
                || version_compare(VersionNumberUtility::getCurrentTypo3Version(), '12.0', '>=')
14✔
29
            )
30
        ) {
31
            $contentObject = static::resolveFromRequest($request);
6✔
32
        }
33

34
        if ($contentObject === null
14✔
35
            && $configurationManager !== null
14✔
36
            && method_exists($configurationManager, 'getContentObject')
14✔
37
        ) {
38
            $contentObject = $configurationManager->getContentObject();
12✔
39
        }
40

41
        return $contentObject;
14✔
42
    }
43

44
    protected static function resolveFromRequest(ServerRequestInterface $request): ?ContentObjectRenderer
45
    {
46
        /** @var TypoScriptFrontendController $controller */
47
        $controller = $request->getAttribute('frontend.controller');
6✔
48
        return $controller instanceof TypoScriptFrontendController ? $controller->cObj : null;
6✔
49
    }
50
}
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