1 | <?php |
||
2 | |||
3 | namespace SilverCommerce\CatalogueAdmin\Search; |
||
4 | |||
5 | use SilverStripe\Forms\CheckboxField; |
||
6 | use SilverStripe\ORM\Search\SearchContext; |
||
7 | |||
8 | class ContactSearchContext extends SearchContext |
||
9 | { |
||
10 | const FILTER_SHOW_FLAGGED = 'ShowFlagged'; |
||
11 | |||
12 | /** |
||
13 | * Overwrite default search fields and update with date ranges and |
||
14 | * a dropdown for status |
||
15 | * |
||
16 | * @return \SilverStripe\Forms\FieldList |
||
17 | */ |
||
18 | public function getSearchFields() |
||
19 | { |
||
20 | $fields = parent::getSearchFields(); |
||
21 | |||
22 | $flagged = CheckboxField::create( |
||
23 | self::FILTER_SHOW_FLAGGED, |
||
24 | _t(__CLASS__ . ".ShowFlaggedOnly", 'Show flagged only') |
||
25 | ); |
||
26 | |||
27 | if ($this->isFlaggedFilterSet()) { |
||
28 | $flagged->setValue(true); |
||
29 | } |
||
30 | |||
31 | $fields->push($flagged); |
||
32 | |||
33 | return $fields; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Add additional search filter to list for date range |
||
38 | * |
||
39 | * @param array $searchParams |
||
40 | * @param array|bool|string $sort |
||
41 | * @param array|bool|string $limit |
||
42 | * @return DataList |
||
0 ignored issues
–
show
|
|||
43 | * @throws Exception |
||
44 | */ |
||
45 | public function getQuery($searchParams, $sort = false, $limit = false, $existingQuery = null) |
||
46 | { |
||
47 | $query = parent::getQuery($searchParams, $sort, $limit); |
||
48 | |||
49 | if ($this->isFlaggedFilterSet()) { |
||
50 | $query = $query->filter('Notes.Flag', true); |
||
51 | } |
||
52 | |||
53 | return $query; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Are we currently only showing flagged contacts |
||
58 | * |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function isFlaggedFilterSet($searchParams = []) |
||
62 | { |
||
63 | if (count($searchParams) == 0) { |
||
64 | $searchParams = $this->getSearchParams(); |
||
65 | } |
||
66 | |||
67 | if (count($searchParams) == 0) { |
||
68 | return false; |
||
69 | } |
||
70 | |||
71 | if (isset($searchParams[self::FILTER_SHOW_FLAGGED])) { |
||
72 | return true; |
||
73 | } |
||
74 | |||
75 | return false; |
||
76 | } |
||
77 | } |
||
78 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths