mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 15:03:44 +08:00
Collect gambits that were matched and applied
This commit is contained in:
parent
7c441f80d4
commit
591de0b4c2
|
@ -13,6 +13,8 @@ class DiscussionSearcher implements SearcherInterface
|
|||
|
||||
protected $relevantPosts = [];
|
||||
|
||||
protected $activeGambits = [];
|
||||
|
||||
protected $gambits;
|
||||
|
||||
protected $discussions;
|
||||
|
@ -44,6 +46,16 @@ class DiscussionSearcher implements SearcherInterface
|
|||
return $this->query->getQuery();
|
||||
}
|
||||
|
||||
public function addActiveGambit($gambit)
|
||||
{
|
||||
$this->activeGambits[] = $gambit;
|
||||
}
|
||||
|
||||
public function getActiveGambits()
|
||||
{
|
||||
return $this->activeGambits;
|
||||
}
|
||||
|
||||
public function search(DiscussionSearchCriteria $criteria, $limit = null, $offset = 0, $load = [])
|
||||
{
|
||||
$this->user = $criteria->user;
|
||||
|
|
|
@ -48,6 +48,7 @@ class GambitManager
|
|||
foreach ($bits as $k => $bit) {
|
||||
foreach ($gambits as $gambit) {
|
||||
if ($gambit->apply($bit, $searcher)) {
|
||||
$searcher->addActiveGambit($gambit);
|
||||
unset($bits[$k]);
|
||||
break;
|
||||
}
|
||||
|
@ -65,6 +66,7 @@ class GambitManager
|
|||
|
||||
$gambit = $this->container->make($this->fulltextGambit);
|
||||
|
||||
$searcher->addActiveGambit($gambit);
|
||||
$gambit->apply($string, $searcher);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user