Passed
Pull Request — master (#2809)
by
unknown
34:29
created

GlobalConfiguration::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 2
nc 2
nop 1
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 ApacheSolrForTypo3\Solr\System\Configuration;
19
20
/**
21
 * This class is used to map TYPO3 global settings like proxy etc. into the unified configuration
22
 *
23
 * @author Lars Tode <[email protected]>
24
 */
25
class GlobalConfiguration implements UnifyConfigurationInterface
26
{
27
    /**
28
     * This array is used in case the configuration need to be customized
29
     *
30
     * @var array|null
31
     */
32
    protected $globals = null;
33
34
    /**
35
     * Allows place own global configuration information.
36
     *
37
     * @param array $globals
38
     */
39
    public function __construct(array $globals = [])
40
    {
41
        if (!empty($globals)) {
42
            $this->globals = $globals;
43
        }
44
    }
45
46
    /**
47
     * Nothing to load
48
     *
49
     * @return UnifyConfigurationInterface
50
     */
51
    public function load(): UnifyConfigurationInterface
52
    {
53
        return $this;
54
    }
55
56
    /**
57
     * {@inheritDoc}
58
     */
59
    public function getUnifiedArray(): array
60
    {
61
        $globals = $this->globals ?? $GLOBALS;
62
        return [
63
            'connection' => [
64
                'read' => $globals['TYPO3_CONF_VARS']['HTTP'],
65
                'write' => $globals['TYPO3_CONF_VARS']['HTTP']
66
            ]
67
        ];
68
    }
69
}
70