Test Failed
Pull Request — master (#9)
by
unknown
05:13
created

EnvBarSiteConfigExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 1
eloc 9
c 3
b 1
f 0
dl 0
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 8 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
        'EnvBarDisplay' => '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
                'EnvBarDisplay',
44
                'Display the environment indicator bar?'
45
            )->setDescription('Check to show the environment indicator bar on'
46
                . ' all pages being viewed in this environment.'),
47
        ]);
48
    }
49
}
50