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

CPS-IT / handlebars-forms / 23477102620

24 Mar 2026 06:57AM UTC coverage: 0.0%. Remained the same
23477102620

push

github

eliashaeussler
[FEATURE] Provide `StringUtility` for better handling of stringables

0 of 26 new or added lines in 5 files covered. (0.0%)

1 existing line in 1 file now uncovered.

0 of 879 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/Classes/ContentObject/AbstractHandlebarsFormsContentObject.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars_forms".
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17

18
namespace CPSIT\Typo3HandlebarsForms\ContentObject;
19

20
use CPSIT\Typo3HandlebarsForms\Utility;
21
use Psr\Log;
22
use TYPO3\CMS\Frontend;
23

24
/**
25
 * AbstractHandlebarsFormsContentObject
26
 *
27
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
28
 * @license GPL-2.0-or-later
29
 */
30
abstract class AbstractHandlebarsFormsContentObject extends Frontend\ContentObject\AbstractContentObject implements Log\LoggerAwareInterface
31
{
32
    use Log\LoggerAwareTrait;
33

34
    private Context\ContextStack $contextStack;
35
    private Context\ValueCollector $valueCollector;
36

37
    public function injectContextStack(Context\ContextStack $contextStack): void
×
38
    {
39
        $this->contextStack = $contextStack;
×
40
    }
41

42
    public function injectValueCollector(Context\ValueCollector $valueCollector): void
×
43
    {
44
        $this->valueCollector = $valueCollector;
×
45
    }
46

47
    /**
48
     * @param array<string, mixed> $conf
49
     */
50
    final public function render($conf = []): string
×
51
    {
52
        $context = $this->contextStack->current();
×
53

54
        if ($context === null) {
×
55
            $this->logger?->warning(
×
56
                'Using a HBS_* content object in other contexts than "process-form" data processor is not supported.',
×
57
            );
×
58

59
            return '';
×
60
        }
61

62
        $value = $this->resolve($conf, $context);
×
63

NEW
64
        if (Utility\StringUtility::isStringable($value)) {
×
NEW
65
            return Utility\StringUtility::processStringable($value, fn(string $string) => $this->applyStdWrap($string, $conf));
×
66
        }
67

68
        return $this->valueCollector->save($this, $value);
×
69
    }
70

71
    /**
72
     * @param array<string, mixed> $configuration
73
     */
74
    abstract protected function resolve(array $configuration, Context\ValueResolutionContext $context): mixed;
×
75

76
    /**
77
     * @param array<string, mixed> $configuration
78
     */
79
    private function applyStdWrap(string $value, array $configuration): string
×
80
    {
81
        if (!is_array($configuration['stdWrap.'] ?? null)) {
×
82
            return $value;
×
83
        }
84

85
        return $this->cObj?->stdWrap($value, $configuration['stdWrap.']) ?? $value;
×
86
    }
87
}
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