Passed
Branch master (c87ba8)
by Christian
16:02
created

SysLogButtonProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTarget() 0 3 1
A __construct() 0 4 1
A getTitle() 0 3 1
A getLink() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace TYPO3\CMS\Dashboard\Widgets\Provider;
19
20
use TYPO3\CMS\Backend\Routing\UriBuilder;
21
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
22
use TYPO3\CMS\Core\Utility\GeneralUtility;
23
use TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface;
24
25
/**
26
 * Provide link for sys log button.
27
 * Check whether belog is enabled and add link to module.
28
 * No link is returned if not enabled.
29
 */
30
class SysLogButtonProvider implements ButtonProviderInterface
31
{
32
    /**
33
     * @var string
34
     */
35
    private $title;
36
37
    /**
38
     * @var string
39
     */
40
    private $target;
41
42
    public function __construct(string $title, string $target = '')
43
    {
44
        $this->title = $title;
45
        $this->target = $target;
46
    }
47
48
    public function getTitle(): string
49
    {
50
        return $this->title;
51
    }
52
53
    public function getLink(): string
54
    {
55
        if (ExtensionManagementUtility::isLoaded('belog')) {
56
            $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
57
            return (string)$uriBuilder->buildUriFromRoute(
58
                'system_BelogLog',
59
                ['tx_belog_system_beloglog[constraint][action]' => -1]
60
            );
61
        }
62
63
        return '';
64
    }
65
66
    public function getTarget(): string
67
    {
68
        return $this->target;
69
    }
70
}
71