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

CustomerServiceBlock::plural_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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
}