Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / search / engineextension / PhabricatorNgramsIndexEngineExtension.php
bloba860d2e2db5199bb21c6e0028e5768a6ac9c480b
1 <?php
3 final class PhabricatorNgramsIndexEngineExtension
4 extends PhabricatorIndexEngineExtension {
6 const EXTENSIONKEY = 'ngrams';
8 public function getExtensionName() {
9 return pht('Ngrams Engine');
12 public function getIndexVersion($object) {
13 $ngrams = $object->newNgrams();
14 $map = mpull($ngrams, 'getValue', 'getNgramKey');
15 ksort($map);
16 $serialized = serialize($map);
18 return PhabricatorHash::digestForIndex($serialized);
21 public function shouldIndexObject($object) {
22 return ($object instanceof PhabricatorNgramsInterface);
25 public function indexObject(
26 PhabricatorIndexEngine $engine,
27 $object) {
29 foreach ($object->newNgrams() as $ngram) {
30 $ngram->writeNgram($object->getID());