1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* SymfonyCommandController. |
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\ClassNamingUtility; |
13
|
|
|
use HDNET\Autoloader\Utility\FileUtility; |
14
|
|
|
use TYPO3\CMS\Core\Utility\ArrayUtility; |
15
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* SymfonyCommandController. |
19
|
|
|
*/ |
20
|
|
|
class SymfonyCommandController implements LoaderInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Get all the complex data and information for the loader. |
24
|
|
|
* This return value will be cached and stored in the core_cache of TYPO3. |
25
|
|
|
* There is no file monitoring for this cache. |
26
|
|
|
* |
27
|
|
|
* @param Loader $loader |
28
|
|
|
* @param int $type |
29
|
|
|
* |
30
|
|
|
* @return array |
31
|
|
|
* |
32
|
|
|
* @see https://docs.typo3.org/typo3cms/InsideTypo3Reference/CoreArchitecture/BackendModules/CliScripts/Index.html |
33
|
|
|
*/ |
34
|
|
|
public function prepareLoader(Loader $loader, int $type): array |
35
|
|
|
{ |
36
|
|
|
$classNames = []; |
37
|
|
|
$commandConfigurationFile = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Configuration/Commands.php'; |
38
|
|
|
|
39
|
|
|
if (\is_file($commandConfigurationFile)) { |
40
|
|
|
return []; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Command/'; |
44
|
|
|
$controllers = FileUtility::getBaseFilesInDir($commandPath, 'php'); |
45
|
|
|
foreach ($controllers as $controller) { |
46
|
|
|
$className = ClassNamingUtility::getFqnByPath( |
47
|
|
|
$loader->getVendorName(), |
48
|
|
|
$loader->getExtensionKey(), |
49
|
|
|
'Command/' . $controller |
50
|
|
|
); |
51
|
|
|
if (!$loader->isInstantiableClass($className)) { |
52
|
|
|
continue; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if (\is_subclass_of($className, \Symfony\Component\Console\Command\Command::class)) { |
|
|
|
|
56
|
|
|
$classNames[\lcfirst($controller)] = $className; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if (empty($classNames)) { |
61
|
|
|
return []; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$configuration = []; |
65
|
|
|
foreach ($classNames as $name => $class) { |
66
|
|
|
$configuration[$loader->getExtensionKey() . ':' . $name] = [ |
67
|
|
|
'class' => $class, |
68
|
|
|
]; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$content = '<?php |
72
|
|
|
// This file is geenrated by EXT:autoloader. If you delete this file, clear the System cache and autoloader will generate a new one ;) |
73
|
|
|
|
74
|
|
|
return ' . ArrayUtility::arrayExport($configuration) . ';'; |
75
|
|
|
|
76
|
|
|
FileUtility::writeFileAndCreateFolder($commandConfigurationFile, $content); |
77
|
|
|
|
78
|
|
|
return $classNames; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Run the loading process for the ext_tables.php file. |
83
|
|
|
* |
84
|
|
|
* @param Loader $loader |
85
|
|
|
* @param array $loaderInformation |
86
|
|
|
*/ |
87
|
|
|
public function loadExtensionTables(Loader $loader, array $loaderInformation) |
88
|
|
|
{ |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Run the loading process for the ext_localconf.php file. |
93
|
|
|
* |
94
|
|
|
* @param Loader $loader |
95
|
|
|
* @param array $loaderInformation |
96
|
|
|
*/ |
97
|
|
|
public function loadExtensionConfiguration(Loader $loader, array $loaderInformation) |
98
|
|
|
{ |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|