Collect gambits that were matched and applied

This commit is contained in:
Toby Zerner 2015-05-06 11:23:35 +09:30
parent 7c441f80d4
commit 591de0b4c2
2 changed files with 14 additions and 0 deletions

View File

@ -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;

View File

@ -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);
}