TypeConverter::loadExtensionConfiguration()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 1
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
/**
4
 * Loading TypeConverter.
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
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
16
17
/**
18
 * Loading TypeConverter.
19
 */
20
class TypeConverter implements LoaderInterface
21
{
22
    /**
23
     * Get all the complex data for the loader.
24
     * This return value will be cached and stored in the database
25
     * There is no file monitoring for this cache.
26
     */
27
    public function prepareLoader(Loader $loader, int $type): array
28
    {
29
        $classes = [];
30
        $converterPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Property/TypeConverter/';
31
        $converterClasses = FileUtility::getBaseFilesRecursivelyInDir($converterPath, 'php', true);
32
33
        foreach ($converterClasses as $converterClass) {
34
            $converterClass = ClassNamingUtility::getFqnByPath(
35
                $loader->getVendorName(),
36
                $loader->getExtensionKey(),
37
                'Property/TypeConverter/' . $converterClass
38
            );
39
            if ($loader->isInstantiableClass($converterClass)) {
40
                $classes[] = $converterClass;
41
            }
42
        }
43
44
        return $classes;
45
    }
46
47
    /**
48
     * Run the loading process for the ext_tables.php file.
49
     */
50
    public function loadExtensionTables(Loader $autoLoader, array $loaderInformation): void
51
    {
52
    }
53
54
    /**
55
     * Run the loading process for the ext_localconf.php file.
56
     */
57
    public function loadExtensionConfiguration(Loader $autoLoader, array $loaderInformation): void
58
    {
59
        foreach ($loaderInformation as $class) {
60
            ExtensionUtility::registerTypeConverter($class);
61
        }
62
    }
63
}
64