|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* handler to create the labels. |
|
5
|
|
|
*/ |
|
6
|
|
|
declare(strict_types = 1); |
|
7
|
|
|
|
|
8
|
|
|
namespace HDNET\Autoloader\Hooks; |
|
9
|
|
|
|
|
10
|
|
|
use HDNET\Autoloader\Annotation\Hook; |
|
11
|
|
|
use HDNET\Autoloader\Localization\LanguageHandler; |
|
12
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* handler to create the labels. |
|
16
|
|
|
* |
|
17
|
|
|
* @Hook("TYPO3_CONF_VARS|EXTCONF|autoloader|assureLabel") |
|
18
|
|
|
*/ |
|
19
|
|
|
class Localization |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Take care that the label exists. |
|
23
|
|
|
* |
|
24
|
|
|
* @param string $key key in the localization file |
|
25
|
|
|
* @param string $extensionName |
|
26
|
|
|
* @param string $default default value of the label |
|
27
|
|
|
* @param array $arguments arguments are being passed over to vsprintf |
|
28
|
|
|
* @param string $tableName The tablename of the given table (null, in non table context) |
|
29
|
|
|
*/ |
|
30
|
|
|
public function assureLabel($key, $extensionName, &$default, $arguments, $tableName): void |
|
31
|
|
|
{ |
|
32
|
|
|
$overrideBaseName = null; |
|
33
|
|
|
if ($this->useTableNameFileBase()) { |
|
34
|
|
|
$overrideBaseName = $tableName; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** @var LanguageHandler $languageHandler */ |
|
38
|
|
|
$languageHandler = GeneralUtility::makeInstance(LanguageHandler::class); |
|
39
|
|
|
$default = $languageHandler->handle($key, $extensionName, $default, $arguments, $overrideBaseName); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Check if table name file base is used. |
|
44
|
|
|
* |
|
45
|
|
|
* @return bool |
|
46
|
|
|
*/ |
|
47
|
|
|
protected function useTableNameFileBase() |
|
48
|
|
|
{ |
|
49
|
|
|
$configuration = unserialize((string)$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['autoloader']); |
|
50
|
|
|
|
|
51
|
|
|
return isset($configuration['enableLanguageFileOnTableBase']) ? (bool)$configuration['enableLanguageFileOnTableBase'] : false; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|