Passed
Pull Request — master (#9)
by
unknown
05:37
created

EnvBarSiteConfigExtension::updateCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Signify\EnvBar\Extensions;
4
5
use BadMethodCallException;
6
use SilverStripe\Forms\CheckboxField;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\ORM\DataExtension;
9
10
/**
11
 * Add override boolean to the site config settings
12
 * @see SilverStripe\SiteConfig\SiteConfig
13
 * to allow CMS admin to disable automatic display of the Environment Indicator
14
 * bar on the frontend pages.
15
 *
16
 * @author Lani Field <[email protected]>
17
 * @version 1.1.0
18
 * @package Signify\EnvBar\Extensions
19
 */
20
class EnvBarSiteConfigExtension extends DataExtension
21
{
22
    /**
23
     * Add override column to SiteConfig db record.
24
     *
25
     * @var string[]
26
     */
27
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
28
        'EnvBarOverride' => 'Boolean',
29
    ];
30
31
    /**
32
     * Add Checkbox field for override value to new Environment Indicator tab
33
     * in CMS Settings.
34
     *
35
     * @param FieldList $fields
36
     * @return void
37
     * @throws BadMethodCallException
38
     */
39
    public function updateCMSFields(FieldList $fields)
40
    {
41
        $fields->addFieldsToTab('Root.EnvironmentIndicator', [
42
            CheckboxField::create(
43
                'EnvBarOverride',
44
                'Tick to turn off the environment indicator bar'
45
            ),
46
        ]);
47
    }
48
}
49