|
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'; |
|
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string Plural name |
|
31
|
|
|
*/ |
|
32
|
|
|
private static $plural_name = 'Solr Cores'; |
|
|
|
|
|
|
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 = [ |
|
|
|
|
|
|
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 |
|
|
|
|
|
|
70
|
|
|
* @param array $context |
|
71
|
|
|
* @return bool |
|
72
|
|
|
*/ |
|
73
|
|
|
public function canCreate($member = null, $context = array()) |
|
74
|
|
|
{ |
|
75
|
|
|
return false; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|