CommandController   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 4
dl 0
loc 49
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareLoader() 0 24 4
A loadExtensionTables() 0 3 1
A loadExtensionConfiguration() 0 6 2
1
<?php
2
3
/**
4
 * Loading CommandController.
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\ExtensionManagementUtility;
15
16
/**
17
 * Loading CommandController.
18
 */
19
class CommandController 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
        $classNames = [];
29
        $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Command/';
30
        $controllers = FileUtility::getBaseFilesInDir($commandPath, 'php');
31
        foreach ($controllers as $controller) {
32
            if ('AbstractCommandController' === $controller) {
33
                continue;
34
            }
35
36
            $className = ClassNamingUtility::getFqnByPath(
37
                $loader->getVendorName(),
38
                $loader->getExtensionKey(),
39
                'Command/' . $controller
40
            );
41
            if (!$loader->isInstantiableClass($className)) {
42
                continue;
43
            }
44
45
            $classNames[] = $className;
46
        }
47
48
        return $classNames;
49
    }
50
51
    /**
52
     * Run the loading process for the ext_tables.php file.
53
     */
54
    public function loadExtensionTables(Loader $loader, array $loaderInformation): void
55
    {
56
    }
57
58
    /**
59
     * Run the loading process for the ext_localconf.php file.
60
     */
61
    public function loadExtensionConfiguration(Loader $loader, array $loaderInformation): void
62
    {
63
        foreach ($loaderInformation as $className) {
64
            $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = $className;
65
        }
66
    }
67
}
68