GridFieldExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 15
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateNewRowClasses() 0 4 2
1
<?php
2
/**
3
 * class GridFieldExtension|Firesphere\SolrSearch\Extensions\GridFieldExtension Add colours to the GridField
4
 *
5
 * @package Firesphere\Solr\Search
6
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
7
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
8
 */
9
10
namespace Firesphere\SolrSearch\Extensions;
11
12
use Firesphere\SolrSearch\Models\SolrLog;
13
use SilverStripe\Core\Extension;
14
use SilverStripe\Forms\GridField\GridField;
15
use SilverStripe\ORM\DataObject;
16
use SilverStripe\View\ViewableData;
17
18
/**
19
 * Class GridFieldExtension
20
 * Dirty hack to get the alert/warning/info classes in to the gridfield
21
 *
22
 * @package Firesphere\Solr\Search
23
 * @property GridField|GridFieldExtension $owner
24
 */
25
class GridFieldExtension extends Extension
26
{
27
28
    /**
29
     * Add the visibility classes to the GridField
30
     *
31
     * @param array $classes
32
     * @param int $total
33
     * @param string $index
34
     * @param DataObject $record
35
     */
36 1
    public function updateNewRowClasses(array &$classes, int $total, string $index, ViewableData $record)
37
    {
38 1
        if ($record instanceof SolrLog) {
39 1
            $classes[] = $record->getExtraClass();
40
        }
41 1
    }
42
}
43