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

CPS-IT / handlebars-forms / 23293182040

19 Mar 2026 11:41AM UTC coverage: 0.0%. Remained the same
23293182040

Pull #12

github

web-flow
Merge de7f87d9b into 7283fb55c
Pull Request #12: feature/cobj decorator

0 of 16 new or added lines in 1 file covered. (0.0%)

0 of 828 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/ContextAwareContentObjectFactory.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 Psr\Http\Message;
21
use Symfony\Component\DependencyInjection;
22
use TYPO3\CMS\Frontend;
23

24
/**
25
 * ContextAwareContentObjectFactory
26
 *
27
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
28
 * @license GPL-2.0-or-later
29
 *
30
 * @internal
31
 */
32
#[DependencyInjection\Attribute\AsDecorator(Frontend\ContentObject\ContentObjectFactory::class)]
33
final readonly class ContextAwareContentObjectFactory
34
{
NEW
35
    public function __construct(
×
36
        #[DependencyInjection\Attribute\AutowireDecorated]
37
        private Frontend\ContentObject\ContentObjectFactory $inner,
38
        private Context\ValueCollector $valueCollector,
NEW
39
    ) {}
×
40

NEW
41
    public function getContentObject(
×
42
        string $name,
43
        Message\ServerRequestInterface $request,
44
        Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer,
45
    ): ?Frontend\ContentObject\AbstractContentObject {
NEW
46
        $contentObject = $this->inner->getContentObject($name, $request, $contentObjectRenderer);
×
47

NEW
48
        if ($contentObject === null) {
×
NEW
49
            return null;
×
50
        }
51

NEW
52
        return new class ($contentObject, $this->valueCollector) extends Frontend\ContentObject\AbstractContentObject {
×
53
            public function __construct(
54
                private readonly Frontend\ContentObject\AbstractContentObject $contentObject,
55
                private readonly Context\ValueCollector $valueCollector,
NEW
56
            ) {}
×
57

58
            /**
59
             * @param array<string|int, mixed> $conf
60
             */
61
            public function render($conf = [])
62
            {
NEW
63
                $value = (string)$this->contentObject->render($conf);
×
64

NEW
65
                if (!$this->valueCollector->has($value)) {
×
NEW
66
                    return $value;
×
67
                }
68

NEW
69
                $resolvedValue = $this->valueCollector->load($value);
×
70

NEW
71
                if (!is_scalar($resolvedValue)) {
×
NEW
72
                    return $value;
×
73
                }
74

NEW
75
                return (string)$resolvedValue;
×
76
            }
NEW
77
        };
×
78
    }
79
}
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