Passed
Push — master ( c38fc4...4e12b6 )
by
unknown
13:55
created

SysLogButtonProvider::getLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Core\Utility\ExtensionManagementUtility;
21
use TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface;
22
use TYPO3\CMS\Dashboard\Widgets\ElementAttributesInterface;
23
24
/**
25
 * Provide link for sys log button.
26
 * Check whether belog is enabled and add link to module.
27
 * No link is returned if not enabled.
28
 */
29
class SysLogButtonProvider implements ButtonProviderInterface, ElementAttributesInterface
30
{
31
    /**
32
     * @var string
33
     */
34
    private $title;
35
36
    /**
37
     * @var string
38
     */
39
    private $target;
40
41
    public function __construct(string $title, string $target = '')
42
    {
43
        $this->title = $title;
44
        $this->target = $target;
45
    }
46
47
    public function getTitle(): string
48
    {
49
        return $this->title;
50
    }
51
52
    public function getLink(): string
53
    {
54
        return '';
55
    }
56
57
    public function getTarget(): string
58
    {
59
        return $this->target;
60
    }
61
62
    public function getElementAttributes(): array
63
    {
64
        if (!ExtensionManagementUtility::isLoaded('belog')) {
65
            return [];
66
        }
67
        return [
68
            'data-dispatch-action' => 'TYPO3.ModuleMenu.showModule',
69
            'data-dispatch-args-list' => 'system_BelogLog,&'
70
                . http_build_query(['tx_belog_system_beloglog' => ['constraint' => ['action' => -1]]]),
71
        ];
72
    }
73
}
74