TemplateOverrideExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 21
ccs 13
cts 13
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 16 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