VersionFeedSiteConfig::updateCMSFields()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 14
rs 9.9332
cc 2
nc 2
nop 1
1
<?php
2
3
namespace SilverStripe\VersionFeed;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\Forms\CheckboxField;
7
use SilverStripe\Forms\FieldGroup;
8
use SilverStripe\Forms\FieldList;
9
use SilverStripe\ORM\DataExtension;
10
11
/**
12
 * Allows global configuration of all changes
13
 */
14
class VersionFeedSiteConfig extends DataExtension
15
{
16
    
17
    private static $db = array(
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
18
        'AllChangesEnabled' => 'Boolean(true)'
19
    );
20
21
    private static $defaults = array(
0 ignored issues
show
introduced by
The private property $defaults is not used, and could be removed.
Loading history...
22
        'AllChangesEnabled' => true
23
    );
24
25
    public function updateFieldLabels(&$labels)
26
    {
27
        $labels['AllChangesEnabled'] = _t(__CLASS__ . '.ALLCHANGESLABEL', 'Make global changes feed public');
28
    }
29
    
30
    public function updateCMSFields(FieldList $fields)
31
    {
32
        if (!Config::inst()->get(VersionFeed::class, 'allchanges_enabled')) {
33
            return;
34
        }
35
36
        $fields->addFieldToTab(
37
            'Root.Access',
38
            FieldGroup::create(new CheckboxField('AllChangesEnabled', $this->owner->fieldLabel('AllChangesEnabled')))
39
                ->setTitle(_t(__CLASS__ . '.ALLCHANGES', 'All page changes'))
40
                ->setDescription(_t(
41
                    'SilverStripe\\VersionFeed\\VersionFeed.Warning',
42
                    "Publicising the history will also disclose the changes that have at the time been protected " .
43
                    "from the public view."
44
                ))
45
        );
46
    }
47
}
48