TcaProcFunc.php 1.04 KB
Newer Older
1
2
3
4
<?php

namespace T3o\T3orgLayout\TCA;

5
6
use Doctrine\DBAL\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\ConnectionPool;
7
8
9
10
11
12
13
14
15
16
use TYPO3\CMS\Core\Utility\GeneralUtility;

class TcaProcFunc
{
    /**
     * @param array $config
     * @return array
     */
    public function feUserItems($config): array
    {
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('fe_users');
        $users = $queryBuilder
            ->select('*')
            ->from('fe_users')
            ->orderBy('name')
            ->execute()
            ->fetchAll();

        $itemList = array();

        if (\is_array($users)) {
            foreach ($users as $user) {
                if ($user['name']) {
                    $label = $user['name'];
32
                } else {
33
                    $label = $user['uid'];
34
                }
35
36
37
                $itemList[] = [$label, $user['username']];
            }
            $config['items'] = $itemList;
38
39
40
41
42
        }

        return $config;
    }
}