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

FluidTYPO3 / vhs / 30001290505

23 Jul 2026 10:57AM UTC coverage: 70.309% (-1.7%) from 72.022%
30001290505

push

github

NamelessCoder
[TER] 8.0.0

4819 of 6854 relevant lines covered (70.31%)

6.54 hits per line

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

36.36
/Classes/ViewHelpers/Resource/CollectionViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Resource;
3

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

11
use FluidTYPO3\Vhs\Core\ViewHelper\AbstractViewHelper;
12
use TYPO3\CMS\Core\Collection\AbstractRecordCollection;
13
use TYPO3\CMS\Core\Collection\RecordCollectionRepository;
14
use TYPO3\CMS\Core\Utility\GeneralUtility;
15

16
/**
17
 * ### Collection ViewHelper
18
 * This viewhelper returns a collection referenced by uid.
19
 * For more information look here:
20
 * http://docs.typo3.org/typo3cms/CoreApiReference/6.2/ApiOverview/Collections/Index.html#collections-api
21
 *
22
 * ### Example
23
 *
24
 * ```
25
 * {v:resource.collection(uid:'123') -> v:var.set(name: 'someCollection')}
26
 * ```
27
 */
28
class CollectionViewHelper extends AbstractViewHelper
29
{
30
    public function initializeArguments(): void
31
    {
32
        $this->registerArgument('uid', 'integer', 'UID of the collection to be rendered', true);
3✔
33
    }
34

35
    /**
36
     * @return string|AbstractRecordCollection
37
     */
38
    public function render()
39
    {
40
        /** @var int $uid */
41
        $uid = $this->arguments['uid'];
3✔
42
        if ($uid > 0) {
3✔
43
            if (!class_exists(RecordCollectionRepository::class)) {
×
44
                throw new \Exception('On TYPO3v12, v:resource.collection requires EXT:legacy_collections', 1670521759);
×
45
            }
46
            /** @var RecordCollectionRepository $collectionRepository */
47
            $collectionRepository = GeneralUtility::makeInstance(RecordCollectionRepository::class);
×
48
            /** @var AbstractRecordCollection $collection */
49
            $collection = $collectionRepository->findByUid($uid);
×
50
            if (null !== $collection) {
×
51
                $collection->loadContents();
×
52
            }
53
            return $collection;
×
54
        }
55
        return '';
3✔
56
    }
57
}
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