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

TYPO3-Headless / headless / 15632475898

13 Jun 2025 10:31AM UTC coverage: 73.085% (-0.05%) from 73.13%
15632475898

push

github

web-flow
[TASK] Set version v2.1 (#816)

[FEATURE] Allow to replace implementation of HeadlessMode

Also introduce option to site settings `headless.preview.overrideMode` to define behaviour in case of mixed mode when click preview button

# Conflicts:
#	Classes/Middleware/ElementBodyResponseMiddleware.php

9 of 9 new or added lines in 7 files covered. (100.0%)

66 existing lines in 3 files now uncovered.

1097 of 1501 relevant lines covered (73.08%)

8.22 hits per line

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

0.0
/Classes/DataProcessing/RootSiteProcessing/SiteSchema.php
1
<?php
2

3
/*
4
 * This file is part of the "headless" Extension for TYPO3 CMS.
5
 *
6
 * For the full copyright and license information, please read the
7
 * LICENSE.md file that was distributed with this source code.
8
 */
9

10
declare(strict_types=1);
11

12
namespace FriendsOfTYPO3\Headless\DataProcessing\RootSiteProcessing;
13

14
use FriendsOfTYPO3\Headless\Utility\HeadlessFrontendUrlInterface;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
17
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
18

19
use function is_array;
20
use function trim;
21

22
class SiteSchema implements SiteSchemaInterface
23
{
24
    public function __construct(
25
        protected HeadlessFrontendUrlInterface $urlUtitlity,
26
        protected ContentDataProcessor $contentDataProcessor
UNCOV
27
    ) {}
×
28

29
    /**
30
     * @param array<string, mixed> $options
31
     * @return array<int, array<string, mixed>>
32
     */
33
    public function process(SiteProviderInterface $provider, array $options = []): array
34
    {
UNCOV
35
        $processorConfiguration = $options['processorConfiguration'] ?? [];
×
UNCOV
36
        $siteUid = (int)($options['siteUid'] ?? 0);
×
UNCOV
37
        $titleField = $processorConfiguration['titleField'] ?? 'title';
×
38

UNCOV
39
        if (trim($titleField) === '') {
×
UNCOV
40
            $titleField = 'title';
×
41
        }
42

43
        $cObj = $options['cObj'] ?? GeneralUtility::makeInstance(ContentObjectRenderer::class);
×
44
        $result = [];
×
45
        $pages = $provider->getPages();
×
46

47
        foreach ($provider->getSites() as $site) {
×
48
            $current = 0;
×
UNCOV
49
            $active = 0;
×
UNCOV
50
            $spacer = 0;
×
51
            $baseUrl = $site->getBase()->getScheme() . '://' . $site->getBase()->getHost();
×
52
            $url = $this->urlUtitlity->getFrontendUrlForPage($baseUrl, $site->getRootPageId());
×
53

UNCOV
54
            if ($provider->getCurrentRootPage() === $site) {
×
55
                $active = 1;
×
56
                if ($site->getRootPageId() === $siteUid) {
×
57
                    $current = 1;
×
58
                }
59
            }
60

UNCOV
61
            $pageInfo = $pages[$site->getRootPageId()];
×
62

63
            $page = [
×
64
                'title' => $pageInfo[$titleField],
×
65
                'link' => $url,
×
UNCOV
66
                'active' => $active,
×
UNCOV
67
                'current' => $current,
×
UNCOV
68
                'spacer' => $spacer,
×
69
            ];
×
70

71
            // process page if necessary
72
            if (isset($processorConfiguration['dataProcessing.']) &&
×
73
                is_array($processorConfiguration['dataProcessing.'])) {
×
74
                $page = $this->processAdditionalDataProcessors(
×
75
                    $page,
×
76
                    $cObj,
×
77
                    $processorConfiguration
×
UNCOV
78
                );
×
79
            }
80

81
            $result[] = $page;
×
82
        }
83

84
        return $result;
×
85
    }
86

87
    /**
88
     * Process additional data processors
89
     *
90
     * @param array<string, mixed> $page
91
     * @param ContentObjectRenderer $cObj
92
     * @param array<string, mixed> $processorConfiguration
93
     * @return array<string, mixed>
94
     */
95
    protected function processAdditionalDataProcessors(
96
        $page,
97
        ContentObjectRenderer $cObj,
98
        $processorConfiguration
99
    ): array {
UNCOV
100
        $cObj->start($page, 'pages');
×
UNCOV
101
        return $this->contentDataProcessor->process($cObj, $processorConfiguration, $page);
×
102
    }
103
}
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