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

FluidTYPO3 / vhs / 30001290505

23 Jul 2026 10:57AM UTC coverage: 70.309% (-1.7%) from 72.022%
30001290505

push

github

NamelessCoder
[TER] 8.0.0

4819 of 6854 relevant lines covered (70.31%)

6.54 hits per line

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

58.82
/Classes/ViewHelpers/Render/AbstractRenderViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Render;
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 FluidTYPO3\Vhs\Core\ViewHelper\AbstractViewHelper;
12
use TYPO3\CMS\Core\Utility\GeneralUtility;
13
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
14
use TYPO3\CMS\Fluid\View\StandaloneView;
15
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
16
use TYPO3Fluid\Fluid\View\TemplateView;
17
use TYPO3Fluid\Fluid\View\ViewInterface;
18

19
/**
20
 * ### Base class for all rendering ViewHelpers.
21
 *
22
 * If errors occur they can be graciously ignored and
23
 * replaced by a small error message or the error itself.
24
 */
25
abstract class AbstractRenderViewHelper extends AbstractViewHelper
26
{
27
    /**
28
     * @var ConfigurationManagerInterface
29
     */
30
    protected $configurationManager;
31

32
    /**
33
     * @var boolean
34
     */
35
    protected $escapeOutput = false;
36

37
    public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void
38
    {
39
        $this->configurationManager = $configurationManager;
27✔
40
    }
41

42
    public function initializeArguments(): void
43
    {
44
        $this->registerArgument(
12✔
45
            'onError',
12✔
46
            'string',
12✔
47
            'Optional error message to display if error occur while rendering. If NULL, lets the error Exception ' .
12✔
48
            'pass trough (and break rendering)'
12✔
49
        );
12✔
50
        $this->registerArgument(
12✔
51
            'graceful',
12✔
52
            'boolean',
12✔
53
            'If forced to FALSE, errors are not caught but rather "transmitted" as every other error would be',
12✔
54
            false,
12✔
55
            false
12✔
56
        );
12✔
57
    }
58

59
    protected static function getPreparedNamespaces(array $arguments): array
60
    {
61
        $namespaces = [];
×
62
        foreach ((array) $arguments['namespaces'] as $namespaceIdentifier => $namespace) {
×
63
            $addedOverriddenNamespace = '{namespace ' . $namespaceIdentifier . '=' . $namespace . '}';
×
64
            $namespaces[] = $addedOverriddenNamespace;
×
65
        }
66
        return $namespaces;
×
67
    }
68

69
    protected static function getPreparedClonedView(RenderingContextInterface $renderingContext): TemplateView
70
    {
71
        $view = static::getPreparedView();
×
72
        $newRenderingContext = $view->getRenderingContext();
×
73
        if (method_exists($renderingContext, 'getRequest') && method_exists($newRenderingContext, 'setRequest')) {
×
74
            $newRenderingContext->setRequest($renderingContext->getRequest());
×
75
        }
76
        $variables = (array) $renderingContext->getVariableProvider()->getAll();
×
77
        $view->assignMultiple($variables);
×
78
        return $view;
×
79
    }
80

81
    /**
82
     * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface|ViewInterface $view
83
     */
84
    protected static function renderView($view, array $arguments): string
85
    {
86
        try {
87
            /** @var string|null $content */
88
            $content = $view->render();
3✔
89
        } catch (\Exception $error) {
3✔
90
            if (!($arguments['graceful'] ?? false)) {
3✔
91
                throw $error;
3✔
92
            }
93
            $content = $error->getMessage() . ' (' . $error->getCode() . ')';
×
94
        }
95
        return (string) $content;
×
96
    }
97

98
    protected static function getPreparedView(): TemplateView
99
    {
100
        /** @var TemplateView $view */
101
        $view = GeneralUtility::makeInstance(TemplateView::class);
3✔
102
        return $view;
3✔
103
    }
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc