1<?php 2 3declare(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 18namespace TYPO3\CMS\Adminpanel\Modules; 19 20use TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter; 21use TYPO3\CMS\Adminpanel\ModuleApi\AbstractModule; 22use TYPO3\CMS\Adminpanel\ModuleApi\ShortInfoProviderInterface; 23use TYPO3\CMS\Core\Log\LogLevel; 24use TYPO3\CMS\Core\Log\LogRecord; 25 26/** 27 * Debug Module of the AdminPanel 28 */ 29class DebugModule extends AbstractModule implements ShortInfoProviderInterface 30{ 31 32 /** 33 * @inheritdoc 34 */ 35 public function getIdentifier(): string 36 { 37 return 'debug'; 38 } 39 40 /** 41 * @inheritdoc 42 */ 43 public function getIconIdentifier(): string 44 { 45 return 'actions-debug'; 46 } 47 48 /** 49 * @inheritdoc 50 */ 51 public function getLabel(): string 52 { 53 return $this->getLanguageService()->sL( 54 'LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:module.label' 55 ); 56 } 57 58 public function getShortInfo(): string 59 { 60 $errorsAndWarnings = array_filter(InMemoryLogWriter::$log, function (LogRecord $entry) { 61 return LogLevel::normalizeLevel($entry->getLevel()) <= 4; 62 }); 63 return sprintf($this->getLanguageService()->sL( 64 'LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:module.shortinfo' 65 ), count($errorsAndWarnings)); 66 } 67} 68