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

FluidTYPO3 / vhs / 12959407058

24 Jan 2025 11:34PM UTC coverage: 72.434% (-0.05%) from 72.481%
12959407058

push

github

web-flow
[FEATURE] Introduce ContentObjectFetcher (#1921)

Adds a common API for reading ContentObjectRenderer instance
in whichever way is appropriate for the host framework version.
Tries all possible locations before giving up.

Close: #1920

13 of 24 new or added lines in 4 files covered. (54.17%)

1 existing line in 1 file now uncovered.

5547 of 7658 relevant lines covered (72.43%)

13.55 hits per line

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

61.54
/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\Extbase\Configuration\ConfigurationManagerInterface;
13
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
14
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
15

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

25
        if ($request && $configurationManager === null) {
126✔
NEW
26
            $contentObject = static::resolveFromRequest($request);
×
27
        }
28

29
        if ($contentObject === null) {
126✔
30
            if ($configurationManager !== null && method_exists($configurationManager, 'getContentObject')) {
126✔
31
                $contentObject = $configurationManager->getContentObject();
126✔
32
            } else {
NEW
33
                $contentObject = static::resolveFromRequest($request);
×
34
            }
35
        }
36

37
        return $contentObject;
126✔
38
    }
39

40
    protected static function resolveFromRequest(ServerRequestInterface $request): ?ContentObjectRenderer
41
    {
42
        /** @var TypoScriptFrontendController $controller */
NEW
43
        $controller = $request->getAttribute('frontend.controller');
×
NEW
44
        return $controller instanceof TypoScriptFrontendController ? $controller->cObj : null;
×
45
    }
46
}
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