CacheTagViewHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeArguments() 0 3 1
A renderStatic() 0 6 1
1
<?php
2
namespace Qbus\Qbtools\ViewHelpers;
3
4
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
5
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
6
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
7
8
/**
9
 * CacheTagViewHelper
10
 *
11
 * @author Benjamin Franzke <[email protected]>
12
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
13
 */
14
class CacheTagViewHelper extends AbstractViewHelper
15
{
16
    use CompileWithRenderStatic;
17
18
    /**
19
     * Initialize arguments
20
     */
21
    public function initializeArguments()
22
    {
23
        $this->registerArgument('tag', 'string', '', true);
24
    }
25
26
    /**
27
     * @param array $arguments
28
     * @param \Closure $renderChildrenClosure
29
     * @param RenderingContextInterface $renderingContext
30
     * @return string
31
     */
32
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
33
    {
34
        $tag = $arguments['tag'];
35
        $GLOBALS['TSFE']->addCacheTags([$tag]);
36
37
        return '';
38
    }
39
}
40