Passed
Push — master ( 19f06a...8d1e35 )
by Ralf
24:17
created

ActiveManagerMenuViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace EWW\Dpf\ViewHelpers;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
class ActiveManagerMenuViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper
18
{
19
20
    public function initializeArguments()
21
    {
22
        parent::initializeArguments();
23
24
        $this->registerArgument('controllerName', 'string',
25
            'The controller to be active.', true
26
        );
27
        $this->registerArgument('actionNames', 'array',
28
            'The actions to be active.', false, []
29
        );
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function render()
36
    {
37
        $controllerName = $this->arguments['controllerName'];
38
        $actionNames = $this->arguments['actionNames'];
39
40
        $controllerContext = $this->renderingContext->getControllerContext();
0 ignored issues
show
Bug introduced by
The method getControllerContext() does not exist on TYPO3Fluid\Fluid\Core\Re...nderingContextInterface. Did you maybe mean getControllerAction()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        /** @scrutinizer ignore-call */ 
41
        $controllerContext = $this->renderingContext->getControllerContext();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
42
        if ($controllerContext->getRequest()->getControllerName() == $controllerName) {
43
44
            if (empty($actionNames)) {
45
                return 'active';
46
            } elseif (in_array($controllerContext->getRequest()->getControllerActionName(), $actionNames)) {
47
                return 'active';
48
            } else {
49
                return '';
50
            }
51
        }
52
53
        return '';
54
    }
55
56
}
57