Completed
Push — master ( 693002...4ea4f2 )
by Tim
08:26 queued 04:02
created

JsonServer::loadExtensionTables()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 6
1
<?php
2
/**
3
 * Loading JsonServer
4
 *
5
 * @author Tim Lochmüller
6
 * @author Tito Duarte <[email protected]>
7
 */
8
9
namespace HDNET\Autoloader\Loader;
10
11
use HDNET\Autoloader\Loader;
12
use HDNET\Autoloader\LoaderInterface;
13
use HDNET\Autoloader\Utility\ClassNamingUtility;
14
use HDNET\Autoloader\Utility\FileUtility;
15
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
16
use TYPO3\CMS\Core\Utility\GeneralUtility;
17
18
/**
19
 * Loading JsonServer
20
 */
21
class JsonServer implements LoaderInterface
22
{
23
24
    /**
25
     * Get all the complex data for the loader.
26
     * This return value will be cached and stored in the database
27
     * There is no file monitoring for this cache
28
     *
29
     * @param Loader $autoLoader
30
     * @param int $type
31
     *
32
     * @return array
33
     */
34
    public function prepareLoader(Loader $autoLoader, $type)
35
    {
36
        $servicePath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Service/Json/';
37
        $serviceClasses = FileUtility::getBaseFilesRecursivelyInDir($servicePath, 'php');
38
39
        $info = [];
40
        foreach ($serviceClasses as $service) {
41
            $serviceClass = ClassNamingUtility::getFqnByPath(
42
                $autoLoader->getVendorName(),
43
                $autoLoader->getExtensionKey(),
44
                'Service/Json/' . $service
45
            );
46
            $info[lcfirst($service)] = $serviceClass;
47
        }
48
49
        return $info;
50
    }
51
52
    /**
53
     * Run the loading process for the ext_tables.php file
54
     *
55
     * @param Loader $autoLoader
56
     * @param array $loaderInformation
57
     *
58
     * @return NULL
59
     */
60
    public function loadExtensionTables(Loader $autoLoader, array $loaderInformation)
61
    {
62
        foreach ($loaderInformation as $key => $class) {
63
            $GLOBALS['TYPO3_CONF_VARS']['AUTOLOADER']['Json'][$key] = $class;
64
        }
65
        return null;
66
    }
67
68
    /**
69
     * Run the loading process for the ext_localconf.php file
70
     *
71
     * @param Loader $autoLoader
72
     * @param array $loaderInformation
73
     *
74
     * @return NULL
75
     */
76
    public function loadExtensionConfiguration(Loader $autoLoader, array $loaderInformation)
77
    {
78
        foreach ($loaderInformation as $key => $class) {
79
            $GLOBALS['TYPO3_CONF_VARS']['AUTOLOADER']['Json'][$key] = $class;
80
        }
81
        return null;
82
    }
83
}
84