Passed
Push — main ( 52a7ec...5410b3 )
by Torben
03:32
created

TitleViewHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 6
c 5
b 0
f 0
dl 0
loc 13
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 5 2
A initializeArguments() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
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 DERHANSEN\SfEventMgt\ViewHelpers;
13
14
use DERHANSEN\SfEventMgt\PageTitle\EventPageTitleProvider;
15
use TYPO3\CMS\Core\Utility\GeneralUtility;
16
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
17
18
/**
19
 * ViewHelper to render the page title and indexed search title
20
 */
21
class TitleViewHelper extends AbstractViewHelper
22
{
23
    public function initializeArguments(): void
24
    {
25
        parent::initializeArguments();
26
        $this->registerArgument('pageTitle', 'String', 'The page title');
27
    }
28
29
    public function render(): void
30
    {
31
        $pageTitle = $this->arguments['pageTitle'] ?? '';
32
        if ($pageTitle !== '') {
33
            GeneralUtility::makeInstance(EventPageTitleProvider::class)->setTitle($pageTitle);
34
        }
35
    }
36
}
37