Completed
Branch master (d17104)
by Christian
21:20
created

TsDebugModule::getTimeTracker()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace TYPO3\CMS\Adminpanel\Modules;
5
6
/*
7
 * This file is part of the TYPO3 CMS project.
8
 *
9
 * It is free software; you can redistribute it and/or modify it under
10
 * the terms of the GNU General Public License, either version 2
11
 * of the License, or any later version.
12
 *
13
 * For the full copyright and license information, please read the
14
 * LICENSE.txt file that was distributed with this source code.
15
 *
16
 * The TYPO3 project - inspiring people to share!
17
 */
18
19
use TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule;
20
use TYPO3\CMS\Adminpanel\ModuleApi\ResourceProviderInterface;
21
use TYPO3\CMS\Adminpanel\ModuleApi\ShortInfoProviderInterface;
22
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
23
use TYPO3\CMS\Core\Utility\GeneralUtility;
24
25
/**
26
 * Admin Panel TypoScript Debug Module
27
 */
28
class TsDebugModule extends AbstractModule implements ShortInfoProviderInterface, ResourceProviderInterface
29
{
30
    /**
31
     * @inheritdoc
32
     */
33
    public function getIdentifier(): string
34
    {
35
        return 'tsdebug';
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function getIconIdentifier(): string
42
    {
43
        return 'mimetypes-x-content-template-static';
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function getLabel(): string
50
    {
51
        return $this->getLanguageService()->sL(
52
            'LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:module.label'
53
        );
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function getShortInfo(): string
60
    {
61
        $messageCount = 0;
62
        foreach ($this->getTimeTracker()->tsStackLog as $log) {
63
            $messageCount += count($log['message'] ?? []);
64
        }
65
        return sprintf(
66
            $this->getLanguageService()->sL(
67
                'LLL:EXT:adminpanel/Resources/Private/Language/locallang_tsdebug.xlf:module.shortinfo'
68
            ),
69
            $messageCount
70
        );
71
    }
72
73
    /**
74
     * @return TimeTracker
75
     */
76
    protected function getTimeTracker(): TimeTracker
77
    {
78
        return GeneralUtility::makeInstance(TimeTracker::class);
79
    }
80
81
    /**
82
     * @inheritdoc
83
     */
84
    public function getJavaScriptFiles(): array
85
    {
86
        return ['EXT:adminpanel/Resources/Public/JavaScript/Modules/TsDebug.js'];
87
    }
88
89
    /**
90
     * @inheritdoc
91
     */
92
    public function getCssFiles(): array
93
    {
94
        return [];
95
    }
96
}
97