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