Completed
Push — v8_compatibility ( 125165 )
by Torben
10:10
created

ParamsViewHelper::getSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
namespace DERHANSEN\SfBanners\ViewHelpers\Flash;
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
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
18
19
/**
20
 * Flash params viewhelper
21
 *
22
 * @author Torben Hansen <[email protected]>
23
 */
24
class ParamsViewHelper extends AbstractViewHelper
25
{
26
    /**
27
     * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
28
     * @inject
29
     */
30
    protected $configurationManager;
31
32
    /**
33
     * Returns TypoSript settings for the extension
34
     *
35
     * @return array
36
     */
37
    public function getSettings()
38
    {
39
        $typoScript = $this->configurationManager->getConfiguration(
40
            \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
41
            'SfBanners',
42
            'Pi1'
43
        );
44
        return $typoScript;
45
    }
46
47
    /**
48
     * Returns the requested flash variable depending on the setting in the banner.
49
     * If no value is set in the banner object, the default value from TS setting
50
     * is returned
51
     *
52
     * @param \DERHANSEN\SfBanners\Domain\Model\Banner $banner The banner
53
     * @param string $flashSetting Flash settings
54
     * @return string
55
     */
56
    public function render($banner = null, $flashSetting = '')
57
    {
58
        $settings = $this->getSettings();
59
        $retVal = '';
60
        switch ($flashSetting) {
61
            case 'wmode':
62
                if ($banner->getFlashWmode() != '') {
63
                    $retVal = $banner->getFlashWmode();
0 ignored issues
show
Bug introduced by
It seems like $banner is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
64
                } else {
65
                    $retVal = $settings['defaultFlashVars']['wmode'];
66
                }
67
                break;
68
            case 'allowScriptAccess':
69
                if ($banner->getFlashAllowScriptAccess() != '') {
70
                    $retVal = $banner->getFlashAllowScriptAccess();
71
                } else {
72
                    $retVal = $settings['defaultFlashVars']['allowScriptAccess'];
73
                }
74
                break;
75
            default:
0 ignored issues
show
Coding Style introduced by
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
76
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
77
        }
78
        return $retVal;
79
    }
80
}
81