1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Loading FlexForms. |
5
|
|
|
*/ |
6
|
|
|
declare(strict_types = 1); |
7
|
|
|
|
8
|
|
|
namespace HDNET\Autoloader\Loader; |
9
|
|
|
|
10
|
|
|
use HDNET\Autoloader\Loader; |
11
|
|
|
use HDNET\Autoloader\LoaderInterface; |
12
|
|
|
use HDNET\Autoloader\Utility\FileUtility; |
13
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
14
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Loading FlexForms. |
18
|
|
|
*/ |
19
|
|
|
class FlexForms implements LoaderInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Get all the complex data for the loader. |
23
|
|
|
* This return value will be cached and stored in the database |
24
|
|
|
* There is no file monitoring for this cache. |
25
|
|
|
*/ |
26
|
|
|
public function prepareLoader(Loader $loader, int $type): array |
27
|
|
|
{ |
28
|
|
|
$flexForms = []; |
29
|
|
|
$flexFormPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Configuration/FlexForms/'; |
30
|
|
|
|
31
|
|
|
// Plugins |
32
|
|
|
$extensionName = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); |
33
|
|
|
$flexFormsFiles = FileUtility::getBaseFilesInDir($flexFormPath, 'xml'); |
34
|
|
|
foreach ($flexFormsFiles as $fileKey) { |
35
|
|
|
$pluginSignature = mb_strtolower($extensionName . '_' . $fileKey); |
36
|
|
|
$flexForms[] = [ |
37
|
|
|
'pluginSignature' => $pluginSignature, |
38
|
|
|
'path' => 'FILE:EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/' . $fileKey . '.xml', |
39
|
|
|
]; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
// Content |
43
|
|
|
$flexFormsFiles = FileUtility::getBaseFilesInDir($flexFormPath . 'Content/', 'xml'); |
44
|
|
|
foreach ($flexFormsFiles as $fileKey) { |
45
|
|
|
$contentSignature = mb_strtolower($loader->getExtensionKey() . '_' . GeneralUtility::camelCaseToLowerCaseUnderscored($fileKey)); |
46
|
|
|
$flexForms[] = [ |
47
|
|
|
'contentSignature' => $contentSignature, |
48
|
|
|
'path' => 'FILE:EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/Content/' . $fileKey . '.xml', |
49
|
|
|
]; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return $flexForms; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Run the loading process for the ext_tables.php file. |
57
|
|
|
*/ |
58
|
|
|
public function loadExtensionTables(Loader $loader, array $loaderInformation): void |
59
|
|
|
{ |
60
|
|
|
foreach ($loaderInformation as $info) { |
61
|
|
|
if (isset($info['pluginSignature'])) { |
62
|
|
|
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$info['pluginSignature']] = 'layout,select_key,recursive'; |
63
|
|
|
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$info['pluginSignature']] = 'pi_flexform'; |
64
|
|
|
ExtensionManagementUtility::addPiFlexFormValue($info['pluginSignature'], $info['path']); |
65
|
|
|
} elseif (isset($info['contentSignature'])) { |
66
|
|
|
$fields = GeneralUtility::trimExplode(',', $GLOBALS['TCA']['tt_content']['types'][$info['contentSignature']]['showitem']); |
67
|
|
|
if (!\in_array('pi_flexform', $fields, true)) { |
68
|
|
|
$GLOBALS['TCA']['tt_content']['types'][$info['contentSignature']]['showitem'] .= ',pi_flexform'; |
69
|
|
|
} |
70
|
|
|
ExtensionManagementUtility::addPiFlexFormValue('*', $info['path'], $info['contentSignature']); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Run the loading process for the ext_localconf.php file. |
77
|
|
|
*/ |
78
|
|
|
public function loadExtensionConfiguration(Loader $loader, array $loaderInformation): void |
79
|
|
|
{ |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|