FreeTextSearchSiteConfig   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 16
c 1
b 0
f 0
dl 0
loc 33
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 15 1
1
<?php declare(strict_types = 1);
2
3
/**
4
 * Created by PhpStorm.
5
 * User: gordon
6
 * Date: 24/3/2561
7
 * Time: 20:36 น.
8
 */
9
10
namespace Suilven\FreeTextSearch\SiteConfig;
11
12
use SilverStripe\Forms\CheckboxField;
13
use SilverStripe\Forms\FieldList;
14
use SilverStripe\Forms\NumericField;
15
use SilverStripe\ORM\DataExtension;
16
17
/**
18
 * Class FreeTextSearchSiteConfig
19
 *
20
 * @package Suilven\FreeTextSearch\SiteConfig
21
 *
22
 *  *
23
 * @package Suilven\FreeTextSearch\Page
24
 * @property int $BulkSize the number of DataObjects to index at once
25
 * @property bool $FreeTextSearchIndexingModeInBulk - show all or no results for an empty query
26
 */
27
class FreeTextSearchSiteConfig extends DataExtension
28
{
29
    /** @var array<string,string> */
30
    private static $db = [
31
        'BulkSize' => 'Int',
32
        'FreeTextSearchIndexingModeInBulk' => 'Boolean',
33
    ];
34
35
    /** @var array<string,int|string|bool> */
36
    private static $defaults = [
37
        'BulkSize' => 500,
38
39
        // if this is not true, it is a build breaker
40
        'FreeTextSearchIndexingModeInBulk' => true,
41
    ];
42
43
44
    /** @return \SilverStripe\Forms\FieldList<\SilverStripe\Forms\FormField> */
45
    public function updateCMSFields(FieldList $fields): FieldList
46
    {
47
        $fields->addFieldToTab("Root.FreeTextSearch", new NumericField(
48
            "BulkSize",
49
            'The number of documents to index at once in bulk'
50
        ));
51
        $fields->addFieldToTab(
52
            'Root.FreeTextSearch',
53
            new CheckboxField(
54
                'FreeTextSearchIndexingModeInBulk',
55
                'True to index in bulk, false to index individually'
56
            )
57
        );
58
59
        return $fields;
60
    }
61
}
62