Passed
Pull Request — master (#103)
by Alexander
03:37
created

JsFooterViewHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeArguments() 0 4 1
A renderStatic() 0 10 1
1
<?php
2
/**
3
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
4
 *
5
 * This file is part of the Kitodo and TYPO3 projects.
6
 *
7
 * @license GNU General Public License version 3 or later.
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 Kitodo\Dlf\ViewHelpers;
13
14
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
15
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
16
use TYPO3\CMS\Core\Page\PageRenderer;
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19
/**
20
 * Add inline JavaScript code to footer *
21
 */
22
class JsFooterViewHelper extends AbstractViewHelper
23
{
24
    /**
25
     * Initialize arguments.
26
     */
27
    public function initializeArguments()
28
    {
29
        parent::initializeArguments();
30
        $this->registerArgument('inlineCode', 'string', 'Inline JavaScript', true);
31
    }
32
33
    /**
34
     *
35
     * @param array $arguments
36
     * @param \Closure $renderChildrenClosure
37
     * @param RenderingContextInterface $renderingContext
38
     */
39
    public static function renderStatic(
40
        array $arguments,
41
        \Closure $renderChildrenClosure,
42
        RenderingContextInterface $renderingContext
43
    ) {
44
        $inlineCode = $arguments['inlineCode'];
45
46
        /** @var $pageRenderer PageRenderer */
47
        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
48
        $pageRenderer->addJsFooterInlineCode('js-dlf-inline-footer', $inlineCode);
49
    }
50
}
51