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

FluidTYPO3 / vhs / 28227939507

26 Jun 2026 08:56AM UTC coverage: 71.316% (+0.1%) from 71.202%
28227939507

Pull #1978

github

web-flow
Merge 1df034b09 into dbe756545
Pull Request #1978: [TASK] Ensure ContentObjectRenderer returned from fetcher

13 of 15 new or added lines in 2 files covered. (86.67%)

4908 of 6882 relevant lines covered (71.32%)

14.76 hits per line

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

94.74
/Classes/Utility/ContentObjectFetcher.php
1
<?php
2
namespace FluidTYPO3\Vhs\Utility;
3

4
/*
5
 * This file is part of the FluidTYPO3/Vhs 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\GeneralUtility;
13
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
14
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
15

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

25
        if ($request instanceof ServerRequestInterface) {
112✔
26
            $contentObject = $request->getAttribute('currentContentObject');
112✔
27
            $contentObject = $contentObject instanceof ContentObjectRenderer ? $contentObject : null;
112✔
28
        }
29

30
        if ($contentObject === null) {
112✔
31
            $controller = RequestResolver::getTypoScriptFrontendController();
99✔
32
            $contentObject = is_object($controller) ? ($controller->cObj ?? null) : null;
99✔
33
            $contentObject = $contentObject instanceof ContentObjectRenderer ? $contentObject : null;
99✔
34
        }
35

36
        if ($contentObject === null
112✔
37
            && $configurationManager !== null
112✔
38
            && method_exists($configurationManager, 'getContentObject')
112✔
39
        ) {
40
            $contentObject = $configurationManager->getContentObject();
87✔
41
            $contentObject = $contentObject instanceof ContentObjectRenderer ? $contentObject : null;
87✔
42
        }
43

44
        if ($contentObject === null) {
112✔
45
            /** @var ContentObjectRenderer $contentObject */
NEW
46
            $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
×
47
        }
48

49
        return $contentObject;
112✔
50
    }
51
}
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