Passed
Push — 1 ( f9fc50...c5209d )
by Morven
05:06
created

GridFieldFilterHeader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSearchContext() 0 11 3
1
<?php
2
3
namespace ilateral\SilverStripe\ModelAdminPlus;
4
5
use SilverStripe\Forms\GridField\GridField;
6
use SilverStripe\Forms\GridField\GridFieldFilterHeader as SSGridFieldFilterHeader;
7
8
/**
9
 * Custom filter header that calls custom model admin search context
10
 */
11
class GridFieldFilterHeader extends SSGridFieldFilterHeader
12
{
13
    public function getSearchContext(GridField $gridField)
14
    {
15
        if (!$this->searchContext) {
16
            $this->searchContext = singleton($gridField->getModelClass())->getModelAdminSearchContext();
17
18
            if ($this->updateSearchContextCallback) {
0 ignored issues
show
Deprecated Code introduced by
The property SilverStripe\Forms\GridF...teSearchContextCallback has been deprecated: 4.3.0:5.0.0 Will be removed in 5.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

18
            if (/** @scrutinizer ignore-deprecated */ $this->updateSearchContextCallback) {

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
19
                call_user_func($this->updateSearchContextCallback, $this->searchContext);
0 ignored issues
show
Deprecated Code introduced by
The property SilverStripe\Forms\GridF...teSearchContextCallback has been deprecated: 4.3.0:5.0.0 Will be removed in 5.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

19
                call_user_func(/** @scrutinizer ignore-deprecated */ $this->updateSearchContextCallback, $this->searchContext);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
20
            }
21
        }
22
23
        return $this->searchContext;
24
    }
25
}
26