BlogPostFeaturedExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 8 1
1
<?php
2
3
namespace SilverStripe\Blog\Model;
4
5
use SilverStripe\ORM\DataExtension;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\CheckboxField;
8
9
/**
10
 * Adds a checkbox field for featured blog posts widget.
11
 */
12
class BlogPostFeaturedExtension extends DataExtension
13
{
14
    /**
15
     * @var array
16
     */
17
    private static $db = [
18
        'FeaturedInWidget' => 'Boolean',
19
    ];
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function updateCMSFields(FieldList $fields)
25
    {
26
        // Add the checkbox in.
27
        $fields->addFieldToTab(
28
            'Root.PostOptions',
29
            CheckboxField::create('FeaturedInWidget', _t(__CLASS__ . '.FEATURED', 'Include Post in Feature Widget'))
30
        );
31
    }
32
}
33