Passed
Pull Request — master (#42)
by
unknown
04:10
created

VersionFeedSiteConfig::updateCMSFields()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
1
<?php
2
3
namespace SilverStripe\VersionFeed;
4
5
6
7
8
9
10
use SilverStripe\Forms\FieldList;
11
use SilverStripe\Core\Config\Config;
12
use SilverStripe\VersionFeed\VersionFeed;
13
use SilverStripe\Forms\CheckboxField;
14
use SilverStripe\Forms\FieldGroup;
15
use SilverStripe\ORM\DataExtension;
16
17
18
19
/**
20
 * Allows global configuration of all changes
21
 */
22
class VersionFeedSiteConfig extends DataExtension {
23
	
24
	private static $db = array(
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
25
		'AllChangesEnabled' => 'Boolean(true)'
26
	);
27
28
	private static $defaults = array(
0 ignored issues
show
introduced by
The private property $defaults is not used, and could be removed.
Loading history...
29
		'AllChangesEnabled' => true
30
	);
31
32
	public function updateFieldLabels(&$labels) {
33
		$labels['AllChangesEnabled'] = _t('VersionFeedSiteConfig.ALLCHANGESLABEL', 'Make global changes feed public');
34
	}
35
	
36
	public function updateCMSFields(FieldList $fields) {
37
		if(!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')) return;
38
39
		$fields->addFieldToTab('Root.Access',
40
			FieldGroup::create(new CheckboxField('AllChangesEnabled', $this->owner->fieldLabel('AllChangesEnabled')))
0 ignored issues
show
Bug introduced by
new SilverStripe\Forms\C...l('AllChangesEnabled')) of type SilverStripe\Forms\CheckboxField is incompatible with the type array expected by parameter $args of SilverStripe\View\ViewableData::create(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
			FieldGroup::create(/** @scrutinizer ignore-type */ new CheckboxField('AllChangesEnabled', $this->owner->fieldLabel('AllChangesEnabled')))
Loading history...
41
				->setTitle(_t('VersionFeedSiteConfig.ALLCHANGES', 'All page changes'))
42
				->setDescription(_t(
43
					'VersionFeed.Warning',
44
					"Publicising the history will also disclose the changes that have at the time been protected " .
45
					"from the public view."
46
				))
47
		);
48
	}
49
}
50