1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace KamiYang\ProjectVersion\Backend\ToolbarItems; |
5
|
|
|
|
6
|
|
|
/* |
7
|
|
|
* This file is part of the ProjectVersion project. |
8
|
|
|
* |
9
|
|
|
* It is free software: you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU General Public License as published by |
11
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
12
|
|
|
* (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* For the full copyright and license information, please read |
15
|
|
|
* LICENSE file that was distributed with this source code. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
use KamiYang\ProjectVersion\Facade\CommandUtilityFacade; |
19
|
|
|
use KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade; |
20
|
|
|
use KamiYang\ProjectVersion\Service\ProjectVersionService; |
21
|
|
|
use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; |
22
|
|
|
use TYPO3\CMS\Core\Localization\LanguageService; |
23
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
24
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
25
|
|
|
use TYPO3\CMS\Core\Utility\StringUtility; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class ProjectVersionSlot |
29
|
|
|
*/ |
30
|
|
|
final class ProjectVersionSlot implements SingletonInterface |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @param \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem $pObj |
34
|
|
|
*/ |
35
|
|
|
public function getProjectVersion(SystemInformationToolbarItem $pObj): void |
36
|
|
|
{ |
37
|
|
|
$projectVersion = $this->getProjectVersionService()->getProjectVersion(); |
38
|
|
|
|
39
|
|
|
$version = $projectVersion->getVersion(); |
40
|
|
|
|
41
|
|
|
if (StringUtility::beginsWith($version, 'LLL:')) { |
42
|
|
|
$version = GeneralUtility::makeInstance(LanguageService::class)->sL($version); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$pObj->addSystemInformation( |
46
|
|
|
$projectVersion->getTitle(), |
47
|
|
|
$version, |
48
|
|
|
$projectVersion->getIconIdentifier() |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return \KamiYang\ProjectVersion\Service\ProjectVersionService |
54
|
|
|
*/ |
55
|
|
|
protected function getProjectVersionService(): ProjectVersionService |
56
|
|
|
{ |
57
|
|
|
$commandUtility = GeneralUtility::makeInstance(CommandUtilityFacade::class); |
58
|
|
|
$systemEnvironmentBuilder = GeneralUtility::makeInstance(SystemEnvironmentBuilderFacade::class); |
59
|
|
|
|
60
|
|
|
return GeneralUtility::makeInstance( |
61
|
|
|
ProjectVersionService::class, |
62
|
|
|
$commandUtility, |
63
|
|
|
$systemEnvironmentBuilder |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|