Completed
Pull Request — master (#62)
by Jason
15:39
created

CustomerServiceBlock   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 53
ccs 12
cts 18
cp 0.6667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A singular_name() 0 4 1
A plural_name() 0 4 1
A getCMSFields() 0 21 2
1
<?php
2
3
namespace Dynamic\DynamicBlocks\Block;
4
5
use SheaDawson\Blocks\Model\Block;
6
use SilverStripe\Forms\EmailField;
7
8 12
class CustomerServiceBlock extends Block
9
{
10 12
    /**
11
     * @return string
12
     */
13
    public function singular_name()
14
    {
15
        return _t('CustomerServiceBlock.SINGULARNAME', 'Customer Service Block');
16 1
    }
17
18 1
    /**
19
     * @return string
20
     */
21
    public function plural_name()
22
    {
23
        return _t('CustomerServiceBlock.PLURALNAME', 'Customer Service Blocks');
24
    }
25
26
    /**
27
     * @var array
28
     */
29
    private static $db = array(
30
        'Title' => 'Varchar(255)',
31
        'Website' => 'Varchar(255)',
32
        'Phone' => 'Varchar(40)',
33
        'Email' => 'Varchar(255)',
34 1
    );
35
36 1
    /**
37
     * @return FieldList
38 1
     */
39
    public function getCMSFields()
40
    {
41
        $fields = parent::getCMSFields();
42
43
        $self =& $this;
44
45
        $this->beforeUpdateCMSFields(function ($fields) use ($self) {
46
            $fields->dataFieldByName('Title')
47
                ->setTitle('Name');
48
            
49 1
            if ($website = $fields->dataFieldByName('Website')) {
50
                $website->setAttribute('placeholder', 'http://');
51 1
            }
52 1
53
            $fields->replaceField('Email', EmailField::create('Email'));
54 1
        });
55
56 1
        //$fields->replaceField('Country', CountryDropdownField::create('Country'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
57
58
        return $fields;
59
    }
60
}