Solr   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A configure_server() 0 17 1
1
<?php
2
/**
3
 * Class Solr|SilverStripe\FullTextSearch\Search\Queries\Solr provide backward compatibility help for
4
 * migrating from the old module
5
 *
6
 * @package SilverStripe\FullTextSearch\Search\Queries
7
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
8
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
9
 */
10
11
namespace SilverStripe\FullTextSearch\Solr;
12
13
use Firesphere\SolrSearch\Services\SolrCoreService;
14
15
/**
16
 * Class Solr Stub to convert old Solr configuration to config
17
 *
18
 * @package SilverStripe\FullTextSearch\Solr
19
 */
20
class Solr
21
{
22
23
    /**
24
     * Compatibility with Fulltext Search module for configurations
25
     *
26
     * @param $config
27
     */
28 1
    public static function configure_server($config): void
29
    {
30
        $configArray = [
31
            'endpoint' => [
32
                'localhost' => [
33 1
                    'host' => $config['host'] ?? '127.0.0.1',
34 1
                    'port' => $config['port'] ?? 8983,
35
                ],
36
            ],
37
        ];
38 1
        SolrCoreService::config()->set('config', $configArray);
39
        $modeArray = [
40 1
            'mode' => $config['indexstore']['mode'] ?? 'file',
41 1
            'path' => $config['indexstore']['path'] ?? '.solr',
42
        ];
43 1
        SolrCoreService::config()->set('mode', $modeArray);
44 1
        SolrCoreService::config()->set('cpucores', $config['cores'] ?? 1);
45 1
    }
46
}
47