1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* BackendLayout. |
5
|
|
|
*/ |
6
|
|
|
declare(strict_types = 1); |
7
|
|
|
|
8
|
|
|
namespace HDNET\Autoloader\Loader; |
9
|
|
|
|
10
|
|
|
use HDNET\Autoloader\Hooks\BackendLayoutProvider; |
11
|
|
|
use HDNET\Autoloader\Loader; |
12
|
|
|
use HDNET\Autoloader\LoaderInterface; |
13
|
|
|
use HDNET\Autoloader\Utility\FileUtility; |
14
|
|
|
use HDNET\Autoloader\Utility\IconUtility; |
15
|
|
|
use HDNET\Autoloader\Utility\TranslateUtility; |
16
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
18
|
|
|
use TYPO3\CMS\Core\Utility\PathUtility; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* BackendLayout loader. |
22
|
|
|
*/ |
23
|
|
|
class BackendLayout implements LoaderInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Get all the complex data and information for the loader. |
27
|
|
|
* This return value will be cached and stored in the core_cache of TYPO3. |
28
|
|
|
* There is no file monitoring for this cache. |
29
|
|
|
*/ |
30
|
|
|
public function prepareLoader(Loader $loader, int $type): array |
31
|
|
|
{ |
32
|
|
|
$backendLayouts = []; |
33
|
|
|
$commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/BackendLayouts/'; |
34
|
|
|
$backendLayoutFiles = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt,typoscript'); |
35
|
|
|
|
36
|
|
|
foreach ($backendLayoutFiles as $file) { |
37
|
|
|
$pathInfo = PathUtility::pathinfo($file); |
38
|
|
|
$iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/BackendLayouts/' . $pathInfo['filename'] . '.'; |
39
|
|
|
$extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath)); |
40
|
|
|
|
41
|
|
|
$translationKey = 'backendLayout.' . $pathInfo['basename']; |
42
|
|
|
if (LoaderInterface::EXT_TABLES === $type) { |
43
|
|
|
TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']); |
44
|
|
|
} |
45
|
|
|
$backendLayouts[] = [ |
46
|
|
|
'path' => 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/BackendLayouts/' . $file, |
47
|
|
|
'filename' => $pathInfo['filename'], |
48
|
|
|
'icon' => $extension ? $iconPath . $extension : false, |
49
|
|
|
'label' => TranslateUtility::getLllString($translationKey, $loader->getExtensionKey()), |
50
|
|
|
'extension' => $loader->getExtensionKey(), |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $backendLayouts; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Run the loading process for the ext_tables.php file. |
59
|
|
|
*/ |
60
|
|
|
public function loadExtensionTables(Loader $loader, array $loaderInformation): void |
61
|
|
|
{ |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Run the loading process for the ext_localconf.php file. |
66
|
|
|
*/ |
67
|
|
|
public function loadExtensionConfiguration(Loader $loader, array $loaderInformation): void |
68
|
|
|
{ |
69
|
|
|
foreach ($loaderInformation as $backendLayout) { |
70
|
|
|
BackendLayoutProvider::addBackendLayoutInformation($backendLayout); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|