SearchableField   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 0%
Metric Value
wmc 4
lcom 0
cbo 6
dl 0
loc 55
ccs 0
cts 18
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 0 13 1
A canDelete() 0 3 1
A canCreate() 0 3 1
A HumanReadableSearchable() 0 4 1
1
<?php
2
3
use SilverStripe\Elastica\ElasticaUtil;
4
5
class SearchableField extends DataObject {
6
	private static $db = array(
7
		'Name' => 'Varchar', // the name of the field, e.g. Title
8
		'ClazzName' => 'Varchar', // the ClassName this field belongs to
9
		'Type' => 'Varchar', // the elasticsearch indexing type,
10
		'ShowHighlights' => 'Boolean', // calculate highlights in Elasticsearch
11
		'Autocomplete' => 'Boolean', // Use this to check for autocomplete fields,
12
		'IsInSiteTree' => 'Boolean' // Set to true if this field originates from a SiteTree object
13
	);
14
15
16
	private static $belongs_many_many = array(
0 ignored issues
show
Unused Code introduced by
The property $belongs_many_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
17
		'ElasticSearchPages' => 'ElasticSearchPage'
18
	);
19
20
	private static $has_one = array('SearchableClass' => 'SearchableClass');
21
22
	private static $display_fields = array('Name');
0 ignored issues
show
Unused Code introduced by
The property $display_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
23
24
25
	public function getCMSFields() {
26
		$fields = new FieldList();
27
		$fields->push( new TabSet( "Root", $mainTab = new Tab( "Main" ) ) );
28
		$mainTab->setTitle( _t( 'SiteTree.TABMAIN', "Main" ) );
29
		$fields->addFieldToTab( 'Root.Main',  $cf = new TextField( 'ClazzName', 'Class sourced from') );
30
		$fields->addFieldToTab( 'Root.Main',  $nf = new TextField( 'Name', 'Name') );
31
		$cf->setDisabled(true);
32
		$nf->setDisabled(true);
33
		$cf->setReadOnly(true);
34
		$nf->setReadOnly(true);
35
36
		return $fields;
37
	}
38
39
	/*
40
	Deletion/inactivity is handled by scripts.  Not end user deletable
41
	 */
42
	public function canDelete($member = null) {
43
		return false;
44
	}
45
46
	/*
47
	Creation is handled by scripts at build time, not end user creatable
48
	 */
49
	public function canCreate($member = null) {
50
		return false;
51
	}
52
53
54
	public function HumanReadableSearchable() {
55
		echo $this->Searchable;
0 ignored issues
show
Bug introduced by
The property Searchable does not seem to exist. Did you mean searchable_fields?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
56
		return ElasticaUtil::showBooleanHumanReadable($this->Searchable);
0 ignored issues
show
Bug introduced by
The property Searchable does not seem to exist. Did you mean searchable_fields?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
57
	}
58
59
}
60