updateCMSFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 1
Metric Value
cc 1
eloc 8
c 2
b 1
f 1
nc 1
nop 1
dl 0
loc 14
ccs 11
cts 11
cp 1
crap 1
rs 9.4285
1
<?php namespace StudioBonito\SilverStripe\GoogleAnalytics\Extensions;
2
3
use FieldList;
4
use TextField;
5
6
/**
7
 * GoogleAnalyticsSiteConfigExtension.
8
 *
9
 * @author       Tom Densham <[email protected]>
10
 * @copyright    Studio Bonito Ltd.
11
 */
12
class GoogleAnalyticsSiteConfigExtension extends \DataExtension
13
{
14
    /**
15
     * List of database fields. {@link DataObject::$db}
16
     *
17
     * @var array
18
     */
19
    private static $db = array(
0 ignored issues
show
Unused Code introduced by
The property $db 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...
20
        'GoogleAnalyticsTrackingID' => 'Varchar(16)',
21
    );
22
23
    /**
24
     * Update list of fields in SiteConfig. Adds all fields inside `Services` parent tab.
25
     *
26
     * @param FieldList $fields
27
     */
28 3
    public function updateCMSFields(FieldList $fields)
29
    {
30 3
        $fields->addFieldsToTab(
31 3
            'Root.Services.GoogleAnalytics',
32
            array(
33 3
                $trackingIdTextField = new TextField(
34 3
                    'GoogleAnalyticsTrackingID',
35 3
                    _t('GoogleAnalytics.TRACKINGID', 'Tracking ID')
36 3
                )
37 3
            )
38 3
        );
39
40 3
        $trackingIdTextField->setDescription(_t('GoogleAnalytics.TRACKINGID_DESC', 'e.g. \'UA-12345678-1\''));
41
    }
42
}