TcaService::addDatabaseItems()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 9.472
c 0
b 0
f 0
cc 3
nc 3
nop 2
1
<?php
2
3
/**
4
 * TcaService.
5
 */
6
7
namespace HDNET\Focuspoint\Service;
8
9
use HDNET\Focuspoint\Domain\Repository\DimensionRepository;
10
use TYPO3\CMS\Core\Utility\GeneralUtility;
11
12
/**
13
 * TcaService.
14
 */
15
class TcaService extends AbstractService
16
{
17
    /**
18
     * Add the custom elements.
19
     *
20
     * @param array  $params
21
     * @param object $parent
22
     */
23
    public function addDatabaseItems(array &$params, $parent)
0 ignored issues
show
Unused Code introduced by
The parameter $parent is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
    {
25
        $customItems = $this->getCustomItems();
26
        if (empty($customItems)) {
27
            \array_unshift($params['items'], [
28
                '',
29
                '',
30
            ]);
31
32
            return;
33
        }
34
35
        // Add element
36
        foreach ($customItems as $item) {
37
            \array_unshift($params['items'], [
38
                $item['dimension'] . ' / ' . $item['title'],
39
                $item['identifier'],
40
            ]);
41
        }
42
        \array_unshift($params['items'], [
43
            'Custom',
44
            '--div--',
45
        ]);
46
        \array_unshift($params['items'], [
47
            '',
48
            '',
49
        ]);
50
    }
51
52
    /**
53
     * Get custom elements.
54
     *
55
     * @return array
56
     */
57
    protected function getCustomItems(): array
58
    {
59
        return GeneralUtility::makeInstance(DimensionRepository::class)->findAll();
60
    }
61
}
62