Completed
Push — master ( e28c49...c020e9 )
by
unknown
19:48
created

ServiceProvider::getHashService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace TYPO3\CMS\Extbase;
19
20
use Psr\Container\ContainerInterface;
21
use TYPO3\CMS\Core\Cache\CacheManager;
22
use TYPO3\CMS\Core\Log\LogManager;
23
use TYPO3\CMS\Core\Package\AbstractServiceProvider;
24
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
25
26
/**
27
 * @internal
28
 */
29
class ServiceProvider extends AbstractServiceProvider
30
{
31
    protected static function getPackagePath(): string
32
    {
33
        return __DIR__ . '/../';
34
    }
35
36
    public function getFactories(): array
37
    {
38
        return [
39
            Object\Container\Container::class => [ static::class, 'getObjectContainer' ],
40
            Object\ObjectManager::class => [ static::class, 'getObjectManager' ],
41
            SignalSlot\Dispatcher::class => [ static::class, 'getSignalSlotDispatcher' ],
42
            Configuration\BackendConfigurationManager::class => [ static::class, 'getBackendConfigurationManager' ],
43
            Configuration\ConfigurationManager::class => [ static::class, 'getConfigurationManager' ],
44
            Reflection\ReflectionService::class => [ static::class, 'getReflectionService' ],
45
            Service\EnvironmentService::class => [ static::class, 'getEnvironmentService' ],
46
            Service\ExtensionService::class => [ static::class, 'getExtensionService' ],
47
            Security\Cryptography\HashService::class => [ static::class, 'getHashService' ],
48
        ];
49
    }
50
51
    public static function getObjectContainer(ContainerInterface $container): Object\Container\Container
52
    {
53
        return self::new($container, Object\Container\Container::class, [$container]);
54
    }
55
56
    public static function getObjectManager(ContainerInterface $container): Object\ObjectManager
57
    {
58
        return self::new($container, Object\ObjectManager::class, [$container, $container->get(Object\Container\Container::class)]);
59
    }
60
61
    public static function getSignalSlotDispatcher(ContainerInterface $container): SignalSlot\Dispatcher
62
    {
63
        $logger = $container->get(LogManager::class)->getLogger(SignalSlot\Dispatcher::class);
64
        return self::new($container, SignalSlot\Dispatcher::class, [$container->get(Object\ObjectManager::class), $logger]);
65
    }
66
67
    public static function getBackendConfigurationManager(ContainerInterface $container): Configuration\BackendConfigurationManager
68
    {
69
        return self::new($container, Configuration\BackendConfigurationManager::class, [
70
            $container->get(Object\ObjectManager::class),
71
            $container->get(TypoScriptService::class),
72
            $container->get(Service\EnvironmentService::class),
73
        ]);
74
    }
75
76
    public static function getConfigurationManager(ContainerInterface $container): Configuration\ConfigurationManager
77
    {
78
        return self::new($container, Configuration\ConfigurationManager::class, [
79
            $container->get(Object\ObjectManager::class),
80
            $container->get(Service\EnvironmentService::class),
81
        ]);
82
    }
83
84
    public static function getReflectionService(ContainerInterface $container): Reflection\ReflectionService
85
    {
86
        return self::new($container, Reflection\ReflectionService::class, [$container->get(CacheManager::class)]);
87
    }
88
89
    public static function getEnvironmentService(ContainerInterface $container): Service\EnvironmentService
90
    {
91
        return self::new($container, Service\EnvironmentService::class);
92
    }
93
94
    public static function getExtensionService(ContainerInterface $container): Service\ExtensionService
95
    {
96
        $extensionService = self::new($container, Service\ExtensionService::class);
97
        $extensionService->injectConfigurationManager($container->get(Configuration\ConfigurationManager::class));
98
        return $extensionService;
99
    }
100
101
    public static function getHashService(ContainerInterface $container): Security\Cryptography\HashService
102
    {
103
        return self::new($container, Security\Cryptography\HashService::class);
104
    }
105
}
106