TemplateOverrideExtension::updateCMSFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1
Metric Value
dl 0
loc 16
ccs 13
cts 13
cp 1
rs 9.4286
cc 1
eloc 11
nc 1
nop 1
crap 1
1
<?php
2
/*
3
Template override extension for the model
4
1) Adds an AlternativeTemplate field
5
2) Ability to edit that
6
*/
7
class TemplateOverrideExtension extends DataExtension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    private static $db = array('AlternativeTemplate' => 'Varchar');
10
11 1
    public function updateCMSFields(FieldList $fields)
12
    {
13 1
        $templatei18n = _t('TemplateOverride.TEMPLATE', 'Template');
14 1
        $fields->addFieldToTab('Root.'.$templatei18n, new TextField('AlternativeTemplate',
15 1
                _t('TemplateOverride.ALTERNATIVE_TEMPLATE_NAME', 'Alternative template name')));
16
17 1
        $info_field = new LiteralField(
18 1
            $name = 'infofield',
19 1
            $content = '<p class="message">'._t('TemplateOverride.INFO', 'If you wish to change'.
20 1
                        ' the default template, type the name of the template here.  Otherwise '.
21 1
                        ' the normal default template will be used.  Normally this will not '.
22 1
                        ' require changing.').'</p>'
23 1
        );
24
25 1
        $fields->addFieldToTab('Root.'.$templatei18n, $info_field);
26 1
    }
27
}
28