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

GridFieldFilterHeader::getSearchContext()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
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