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

FluidTYPO3 / flux / 12237686280

09 Dec 2024 02:27PM UTC coverage: 92.9% (-0.5%) from 93.421%
12237686280

push

github

NamelessCoder
[TER] 10.1.0

7013 of 7549 relevant lines covered (92.9%)

56.22 hits per line

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

18.18
/Classes/Integration/Overrides/BackendLayoutView.php
1
<?php
2
declare(strict_types=1);
3
namespace FluidTYPO3\Flux\Integration\Overrides;
4

5
/*
6
 * This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.md file that was distributed with this source code.
10
 */
11

12
use FluidTYPO3\Flux\Provider\Interfaces\GridProviderInterface;
13
use FluidTYPO3\Flux\Provider\ProviderResolver;
14
use FluidTYPO3\Flux\Utility\DoctrineQueryProxy;
15
use TYPO3\CMS\Core\Database\ConnectionPool;
16
use TYPO3\CMS\Core\Utility\GeneralUtility;
17

18
class BackendLayoutView extends \TYPO3\CMS\Backend\View\BackendLayoutView
19
{
20
    protected ?GridProviderInterface $provider = null;
21
    protected array $record = [];
22

23
    public function setProvider(GridProviderInterface $provider): void
24
    {
25
        $this->provider = $provider;
7✔
26
    }
27

28
    public function setRecord(array $record): void
29
    {
30
        $this->record = $record;
7✔
31
    }
32

33
    /**
34
     * @param int $pageId
35
     */
36
    public function getSelectedBackendLayout($pageId): ?array
37
    {
38
        // Delegate resolving of backend layout structure to the Provider, which will return a Grid, which can create
39
        // a full backend layout data array.
40
        if ($this->provider instanceof GridProviderInterface) {
×
41
            return $this->provider->getGrid($this->record)->buildExtendedBackendLayoutArray(
×
42
                $this->resolveParentRecordUid($this->record)
×
43
            );
×
44
        }
45
        return parent::getSelectedBackendLayout($pageId);
×
46
    }
47

48
    /**
49
     * Extracts the UID to use as parent UID, based on properties of the record
50
     * and composition of the values within it, to ensure an integer UID.
51
     */
52
    protected function resolveParentRecordUid(array $record): int
53
    {
54
        $uid = $record['l18n_parent'] ?: $record['uid'];
×
55
        if (is_array($uid)) {
×
56
            // The record was passed by a third-party integration which read the record from FormEngine's expanded
57
            // format which stores select-type fields such as the l18n_parent as array values. Extract it from there.
58
            return $uid = reset($uid);
×
59
        }
60
        return (int) $uid;
×
61
    }
62

63
    /**
64
     * @codeCoverageIgnore
65
     */
66
    protected function loadRecordFromTable(string $table, int $uid): ?array
67
    {
68
        /** @var ConnectionPool $connectionPool */
69
        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
70
        $queryBuilder = $connectionPool->getQueryBuilderForTable($table);
71
        $query = $queryBuilder->select('*')
72
            ->from($table)
73
            ->where($queryBuilder->expr()->eq('uid', $uid));
74
        $query->getRestrictions()->removeAll();
75
        /** @var array[] $results */
76
        $results = DoctrineQueryProxy::fetchAllAssociative(DoctrineQueryProxy::executeQueryOnQueryBuilder($query));
77
        return $results[0] ?? null;
78
    }
79

80
    /**
81
     * @codeCoverageIgnore
82
     */
83
    protected function resolvePrimaryProviderForRecord(string $table, array $record): ?GridProviderInterface
84
    {
85
        /** @var ProviderResolver $providerResolver */
86
        $providerResolver = GeneralUtility::makeInstance(ProviderResolver::class);
87
        return $providerResolver->resolvePrimaryConfigurationProvider(
88
            $table,
89
            null,
90
            $record,
91
            null,
92
            [GridProviderInterface::class]
93
        );
94
    }
95
}
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