Passed
Push — typo3_11 ( 5ba873...996200 )
by Torben
06:47
created

BackendUserViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\ViewHelpers\Be;
13
14
use TYPO3\CMS\Core\Database\ConnectionPool;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
17
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
18
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
19
20
/**
21
 * ViewHelper to render details about the given backend user
22
 */
23
class BackendUserViewHelper extends AbstractViewHelper
24
{
25
    use CompileWithRenderStatic;
26
27
    /**
28
     * Initialize arguments
29
     */
30
    public function initializeArguments()
31
    {
32
        $this->registerArgument('userUid', 'int', 'UID of backend user', true);
33
    }
34
35
    /**
36
     * @param array $arguments
37
     * @param \Closure $renderChildrenClosure
38
     * @param RenderingContextInterface $renderingContext
39
     * @return array|false|mixed
40
     * @throws \Doctrine\DBAL\Driver\Exception
41
     */
42
    public static function renderStatic(
43
        array $arguments,
44
        \Closure $renderChildrenClosure,
45
        RenderingContextInterface $renderingContext
46
    ) {
47
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
48
        $queryBuilder->getRestrictions()->removeAll();
49
        return $queryBuilder
50
            ->select('*')
51
            ->from('be_users')
52
            ->where(
53
                $queryBuilder->expr()->eq(
54
                    'uid',
55
                    $queryBuilder->createNamedParameter($arguments['userUid'], \PDO::PARAM_INT)
56
                )
57
            )
58
            ->execute()
59
            ->fetchAssociative();
60
    }
61
}
62