Passed
Push — hans/core-specific-configs ( 7670cf )
by Simon
09:28
created

SolrCore::getCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Class Firesphere\SolrSearch\Models\SolrCore For managing Solr cores in the cms
4
 *
5
 * @package Firesphere\SolrSearch\Models
6
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
7
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
8
 */
9
10
namespace Firesphere\SolrSearch\Models;
11
12
use SilverStripe\Forms\FieldList;
13
use SilverStripe\ORM\DataObject;
14
15
/**
16
 * Class SolrCore
17
 * @package Firesphere\SolrSearch\Models
18
 */
19
class SolrCore extends DataObject
20
{
21
    /**
22
     * @var string Table name for this class
23
     */
24
    private static $table_name = 'SolrCore';
25
    /**
26
     * @var string Singular name
27
     */
28
    private static $singular_name = 'Solr core';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
29
    /**
30
     * @var string Plural name
31
     */
32
    private static $plural_name = 'Solr Cores';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
33
    /**
34
     * @var array Database fields
35
     */
36
    private static $db = [
37
        'Title' => 'Varchar(255)'
38
    ];
39
    /**
40
     * @var array Synonyms and Logs related to this core
41
     */
42
    private static $has_many = [
43
        'SearchSynonyms' => SearchSynonym::class,
44
        'SolrLogs'       => SolrLog::class,
45
    ];
46
    /**
47
     * @var array Dirty classes this core has
48
     */
49
    private static $many_many = [
0 ignored issues
show
introduced by
The private property $many_many is not used, and could be removed.
Loading history...
50
        'DirtyClasses' => DirtyClass::class
51
    ];
52
53
    /**
54
     * Update the CMS to make the Title uneditable
55
     *
56
     * @return FieldList
57
     */
58
    public function getCMSFields()
59
    {
60
        $fields = parent::getCMSFields();
61
        $fields->dataFieldByName('Title')->setReadonly(true)->setDisabled(true);
62
63
        return $fields;
64
    }
65
66
    /**
67
     * You can't create a Core DataObject manually. It requires a Solr core to exist.
68
     *
69
     * @param null $member
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
70
     * @param array $context
71
     * @return bool
72
     */
73
    public function canCreate($member = null, $context = array())
74
    {
75
        return false;
76
    }
77
}
78