@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 73 lines 1.6 kB view raw
1<?php 2 3final class PhabricatorFerretSearchEngineExtension 4 extends PhabricatorSearchEngineExtension { 5 6 const EXTENSIONKEY = 'ferret'; 7 8 public function isExtensionEnabled() { 9 return true; 10 } 11 12 public function getExtensionName() { 13 return pht('Fulltext Search'); 14 } 15 16 public function getExtensionOrder() { 17 return 1000; 18 } 19 20 public function supportsObject($object) { 21 return ($object instanceof PhabricatorFerretInterface); 22 } 23 24 public function applyConstraintsToQuery( 25 $object, 26 $query, 27 PhabricatorSavedQuery $saved, 28 array $map) { 29 30 if (!(isset($map['query']) && strlen($map['query']))) { 31 return; 32 } 33 34 $engine = $object->newFerretEngine(); 35 36 $raw_query = $map['query']; 37 38 $compiler = id(new PhutilSearchQueryCompiler()) 39 ->setEnableFunctions(true); 40 41 $raw_tokens = $compiler->newTokens($raw_query); 42 43 $fulltext_tokens = array(); 44 foreach ($raw_tokens as $raw_token) { 45 $fulltext_token = id(new PhabricatorFulltextToken()) 46 ->setToken($raw_token); 47 48 $fulltext_tokens[] = $fulltext_token; 49 } 50 51 $query->withFerretConstraint($engine, $fulltext_tokens); 52 } 53 54 public function getSearchFields($object) { 55 $fields = array(); 56 57 $fields[] = id(new PhabricatorSearchTextField()) 58 ->setKey('query') 59 ->setLabel(pht('Query')) 60 ->setDescription( 61 pht( 62 'Find objects matching a fulltext search query. See '. 63 '"Search User Guide" in the documentation for details.')); 64 65 return $fields; 66 } 67 68 public function getSearchAttachments($object) { 69 return array(); 70 } 71 72 73}