‪TYPO3CMS  ‪main
SystemInformationController.php
Go to the documentation of this file.
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 
19 
29 
36 {
38 
39  public function ‪__construct(array ‪$backendUserConfiguration = null)
40  {
41  $this->backendUserConfiguration = ‪$backendUserConfiguration ?? ‪$GLOBALS['BE_USER']->uc;
42  }
43 
48  #[AsEventListener('belog/show-latest-errors')]
50  {
51  $systemInformationToolbarItem = $event->‪getToolbarItem();
52  // we can't use the extbase repository here as the required TypoScript may not be parsed yet
53  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_log');
54  $count = $queryBuilder->count('error')
55  ->from('sys_log')
56  ->where(
57  $queryBuilder->expr()->gte(
58  'tstamp',
59  $queryBuilder->createNamedParameter($this->fetchLastAccessTimestamp(), ‪Connection::PARAM_INT)
60  ),
61  $queryBuilder->expr()->in(
62  'error',
63  $queryBuilder->createNamedParameter([-1, 1, 2], ‪Connection::PARAM_INT_ARRAY)
64  )
65  )
66  ->executeQuery()
67  ->fetchOne();
68 
69  if ($count > 0) {
70  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
71  $moduleIdentifier = 'system_BelogLog';
72  $moduleParams = ['constraint' => ['channel' => 'php']];
73  $systemInformationToolbarItem->addSystemMessage(
74  sprintf(
75  $this->‪getLanguageService()->sL('LLL:EXT:belog/Resources/Private/Language/locallang.xlf:systemmessage.errorsInPeriod'),
76  $count,
77  (string)$uriBuilder->buildUriFromRoute($moduleIdentifier, $moduleParams)
78  ),
79  InformationStatus::ERROR,
80  $count,
81  $moduleIdentifier,
82  http_build_query($moduleParams)
83  );
84  }
85  }
86 
87  private function ‪fetchLastAccessTimestamp(): int
88  {
89  if (!isset($this->backendUserConfiguration['systeminformation'])) {
90  return 0;
91  }
92  $systemInformationUc = json_decode($this->backendUserConfiguration['systeminformation'], true);
93  if (!isset($systemInformationUc['system_BelogLog']['lastAccess'])) {
94  return 0;
95  }
96 
97  return (int)$systemInformationUc['system_BelogLog']['lastAccess'];
98  }
99 
101  {
102  return ‪$GLOBALS['LANG'];
103  }
104 }
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:52
‪TYPO3\CMS\Belog\Controller\SystemInformationController\$backendUserConfiguration
‪array $backendUserConfiguration
Definition: SystemInformationController.php:37
‪TYPO3\CMS\Core\Attribute\AsEventListener
Definition: AsEventListener.php:25
‪TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent
Definition: SystemInformationToolbarCollectorEvent.php:27
‪TYPO3\CMS\Backend\Toolbar\InformationStatus
‪InformationStatus
Definition: InformationStatus.php:24
‪TYPO3\CMS\Belog\Controller
Definition: BackendLogController.php:18
‪TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
Definition: RouteNotFoundException.php:21
‪TYPO3\CMS\Belog\Controller\SystemInformationController
Definition: SystemInformationController.php:36
‪TYPO3\CMS\Belog\Controller\SystemInformationController\fetchLastAccessTimestamp
‪fetchLastAccessTimestamp()
Definition: SystemInformationController.php:87
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:44
‪TYPO3\CMS\Belog\Controller\SystemInformationController\getLanguageService
‪getLanguageService()
Definition: SystemInformationController.php:100
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:41
‪TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent\getToolbarItem
‪getToolbarItem()
Definition: SystemInformationToolbarCollectorEvent.php:30
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Belog\Controller\SystemInformationController\appendMessage
‪appendMessage(SystemInformationToolbarCollectorEvent $event)
Definition: SystemInformationController.php:49
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Belog\Controller\SystemInformationController\__construct
‪__construct(array $backendUserConfiguration=null)
Definition: SystemInformationController.php:39
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT_ARRAY
‪const PARAM_INT_ARRAY
Definition: Connection.php:72