Completed
Push — development ( e28f2a...f347c3 )
by Torben
02:54
created

TitleViewHelper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeArguments() 0 11 1
B renderStatic() 0 14 5
1
<?php
2
namespace DERHANSEN\SfEventMgt\ViewHelpers;
3
4
/*
5
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.txt file that was distributed with this source code.
9
 */
10
11
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
12
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
13
use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
14
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
15
16
/**
17
 * ViewHelper to render the page title and indexed search title
18
 */
19
class TitleViewHelper extends AbstractViewHelper implements CompilableInterface
20
{
21
    use CompileWithRenderStatic;
22
23
    /**
24
     * Initialize arguments
25
     */
26
    public function initializeArguments()
27
    {
28
        parent::initializeArguments();
29
        $this->registerArgument('pageTitle', 'String', 'The page title');
30
        $this->registerArgument(
31
            'indexedDocTitle',
32
            'string',
33
            'The title for the event in indexed search result',
34
            false
35
        );
36
    }
37
38
    /**
39
     * @param array $arguments
40
     * @param \Closure $renderChildrenClosure
41
     * @param RenderingContextInterface $renderingContext
42
     */
43
    public static function renderStatic(
44
        array $arguments,
45
        \Closure $renderChildrenClosure,
46
        RenderingContextInterface $renderingContext
47
    ) {
48
        $pageTitle = isset($arguments['pageTitle']) ? $arguments['pageTitle'] : '';
49
        $indexedDocTitle = isset($arguments['indexedDocTitle']) ? $arguments['indexedDocTitle'] : $pageTitle;
50
        if ($pageTitle !== '') {
51
            $GLOBALS['TSFE']->altPageTitle = $pageTitle;
52
        }
53
        if ($indexedDocTitle !== '') {
54
            $GLOBALS['TSFE']->indexedDocTitle = $indexedDocTitle;
55
        }
56
    }
57
}
58