SearchableField::HumanReadableSearchable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 3
nc 1
nop 0
crap 2
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