SitewideContentReview   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateColumns() 0 26 3
1
<?php
2
3
namespace SilverStripe\SiteWideContentReport\Model;
4
5
use SilverStripe\Core\Extension;
6
7
/**
8
 * Provides contentreview integration for sitewide content report.
9
 *
10
 * Requires https://github.com/silverstripe/silverstripe-contentreview
11
 * Class SitewideContentReview
12
 * @package SilverStripe\SiteWideContentReport\Model
13
 */
14
class SitewideContentReview extends Extension
15
{
16
    /**
17
     * Update columns to include subsite details.
18
     *
19
     * @param string $itemType (i.e 'Pages' or 'Files')
20
     * @param array $columns Columns
21
     * @return mixed
22
     */
23
    public function updateColumns($itemType, &$columns)
24
    {
25
        if ($itemType !== 'Pages') {
26
            return;
27
        }
28
29
        // {@see SiteTreeContentReview::getOwnerNames()}
30
        $columns['OwnerNames'] = [
31
            'printonly' => true, // Hide on page report
32
            'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.Reviewer', 'Reviewer'),
33
        ];
34
35
        // {@see SiteTreeContentView::getReviewDate()}
36
        $columns['ReviewDate'] = [
37
            'printonly' => true, // Hide on page report
38
            'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.ReviewDate', 'Review Date'),
39
            'formatting' => function ($value, $record) {
40
                if ($val = $record->getReviewDate()) {
41
                    return $val->Nice();
42
                }
43
44
                return null;
45
            },
46
        ];
47
48
        return;
49
    }
50
}
51