20
20
use MonsieurBiz \SyliusSearchPlugin \Search \Request \PostFilter \PostFilterInterface ;
21
21
use MonsieurBiz \SyliusSearchPlugin \Search \Request \QueryFilter \QueryFilterInterface ;
22
22
use MonsieurBiz \SyliusSearchPlugin \Search \Request \Sorting \SorterInterface ;
23
+ use RuntimeException ;
23
24
use Sylius \Component \Channel \Context \ChannelContextInterface ;
24
25
use Sylius \Component \Registry \ServiceRegistryInterface ;
25
26
@@ -82,30 +83,34 @@ public function getType(): string
82
83
83
84
public function getDocumentable (): DocumentableInterface
84
85
{
85
- /** @var DocumentableInterface $documentable */
86
+ /** @phpstan-ignore-next-line */
86
87
return $ this ->documentableRegistry ->get ('search.documentable. ' . $ this ->documentType );
87
88
}
88
89
89
90
public function getQuery (): Query
90
91
{
92
+ if (!($ configuration = $ this ->configuration )) {
93
+ throw new RuntimeException ('Configuration is not set ' );
94
+ }
95
+
91
96
$ qb = new QueryBuilder ();
92
97
93
98
$ boolQuery = $ qb ->query ()->bool ();
94
99
foreach ($ this ->queryFilters as $ queryFilter ) {
95
- $ queryFilter ->apply ($ boolQuery , $ this -> configuration );
100
+ $ queryFilter ->apply ($ boolQuery , $ configuration );
96
101
}
97
102
98
103
$ query = Query::create ($ boolQuery );
99
104
$ postFilter = new Query \BoolQuery ();
100
105
foreach ($ this ->postFilters as $ postFilterApplier ) {
101
- $ postFilterApplier ->apply ($ postFilter , $ this -> configuration );
106
+ $ postFilterApplier ->apply ($ postFilter , $ configuration );
102
107
}
103
108
$ query ->setPostFilter ($ postFilter );
104
109
105
110
$ this ->addAggregations ($ query , $ postFilter );
106
111
107
112
foreach ($ this ->sorters as $ sorter ) {
108
- $ sorter ->apply ($ query , $ this -> configuration );
113
+ $ sorter ->apply ($ query , $ configuration );
109
114
}
110
115
111
116
/** @var Query\AbstractQuery $queryObject */
@@ -116,7 +121,7 @@ public function getQuery(): Query
116
121
->setScoreMode (Query \FunctionScore::SCORE_MODE_MULTIPLY )
117
122
;
118
123
foreach ($ this ->functionScores as $ functionScoreClass ) {
119
- $ functionScoreClass ->addFunctionScore ($ functionScore , $ this -> configuration );
124
+ $ functionScoreClass ->addFunctionScore ($ functionScore , $ configuration );
120
125
}
121
126
122
127
$ query ->setQuery ($ functionScore );
0 commit comments