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

CPS-IT / handlebars / 34327921175

09 Sep 2026 08:13AM UTC coverage: 87.548% (-3.0%) from 90.565%
34327921175

Pull #636

github

web-flow
Merge 66057bfd8 into 59b9b577d
Pull Request #636: [FEATURE] Introduce `media` processor

0 of 61 new or added lines in 3 files covered. (0.0%)

1603 of 1831 relevant lines covered (87.55%)

7.08 hits per line

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

0.0
/Classes/DataProcessing/Media/ConfigurableProcessor.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars".
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\Typo3Handlebars\DataProcessing\Media;
19

20
use CuyZ\Valinor;
21
use Symfony\Component\DependencyInjection;
22
use TYPO3\CMS\Core;
23
use TYPO3\CMS\Extbase;
24
use TYPO3\CMS\Frontend;
25

26
/**
27
 * ConfigurableProcessor
28
 *
29
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
30
 * @license GPL-2.0-or-later
31
 *
32
 * @template T of Configuration\Configuration
33
 */
34
abstract class ConfigurableProcessor implements MediaProcessor
35
{
36
    private ?Core\Cache\Frontend\FrontendInterface $cache = null;
37
    private ?Valinor\Mapper\TreeMapper $mapper = null;
38

NEW
39
    public function injectCache(
×
40
        #[DependencyInjection\Attribute\Autowire(expression: 'service("TYPO3\\\\CMS\\\\Core\\\\Cache\\\\CacheManager").getCache("handlebars_media")')]
41
        Core\Cache\Frontend\FrontendInterface $cache,
42
    ): void {
NEW
43
        $this->cache = $cache;
×
44
    }
45

46
    /**
47
     * @throws Valinor\Mapper\MappingError
48
     */
NEW
49
    public function process(
×
50
        Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer,
51
        Extbase\Domain\Model\File|Core\Resource\ResourceInterface|Extbase\Domain\Model\FileReference $resource,
52
        array $configuration = [],
53
    ): array {
NEW
54
        $this->mapper ??= $this->createMapper();
×
55

NEW
56
        return $this->processFile(
×
NEW
57
            $contentObjectRenderer,
×
NEW
58
            $resource,
×
NEW
59
            $this->mapper->map($this->getConfigurationClass(), $configuration),
×
NEW
60
        );
×
61
    }
62

63
    /**
64
     * @param T $configuration
65
     * @return array<string, mixed>
66
     */
67
    abstract protected function processFile(
68
        Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer,
69
        Extbase\Domain\Model\File|Core\Resource\ResourceInterface|Extbase\Domain\Model\FileReference $resource,
70
        Configuration\Configuration $configuration,
71
    ): array;
72

73
    /**
74
     * @return class-string<T>
75
     */
76
    abstract protected function getConfigurationClass(): string;
77

NEW
78
    protected function createMapper(): Valinor\Mapper\TreeMapper
×
79
    {
NEW
80
        $mapperBuilder = (new Valinor\MapperBuilder())
×
NEW
81
            ->allowCastingToBoolean()
×
NEW
82
            ->allowCastingToInteger()
×
NEW
83
            ->allowNonSequentialList()
×
NEW
84
        ;
×
85

NEW
86
        if (($cacheBackend = $this->cache?->getBackend()) instanceof Core\Cache\Backend\SimpleFileBackend) {
×
NEW
87
            $mapperBuilder = $mapperBuilder->withCache(new Valinor\Cache\FileSystemCache($cacheBackend->getCacheDirectory()));
×
NEW
88
            $mapperBuilder->warmupCacheFor($this->getConfigurationClass());
×
89
        }
90

NEW
91
        return $mapperBuilder->mapper();
×
92
    }
93
}
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