@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
at recaptime-dev/main 58 lines 1.5 kB view raw
1<?php 2 3final class DiffusionInternalCommitSearchConduitAPIMethod 4 extends PhabricatorSearchEngineAPIMethod { 5 6 public function getAPIMethodName() { 7 return 'internal.commit.search'; 8 } 9 10 public function newSearchEngine() { 11 return new DiffusionInternalCommitSearchEngine(); 12 } 13 14 public function getMethodSummary() { 15 return pht('Read raw information about commits.'); 16 } 17 18 protected function newConduitCallProxyClient(ConduitAPIRequest $request) { 19 $viewer = $request->getViewer(); 20 21 $constraints = $request->getValue('constraints'); 22 if (is_array($constraints)) { 23 $repository_phids = idx($constraints, 'repositoryPHIDs'); 24 } else { 25 $repository_phids = array(); 26 } 27 28 $repository_phid = null; 29 if (is_array($repository_phids)) { 30 if (phutil_is_natural_list($repository_phids)) { 31 if (count($repository_phids) === 1) { 32 $value = head($repository_phids); 33 if (is_string($value)) { 34 $repository_phid = $value; 35 } 36 } 37 } 38 } 39 40 if ($repository_phid === null) { 41 throw new Exception( 42 pht( 43 'This internal method must be invoked with a "repositoryPHIDs" '. 44 'constraint with exactly one value.')); 45 } 46 47 $repository = id(new PhabricatorRepositoryQuery()) 48 ->setViewer($viewer) 49 ->withPHIDs(array($repository_phid)) 50 ->executeOne(); 51 if (!$repository) { 52 return array(); 53 } 54 55 return $repository->newConduitClientForRequest($request); 56 } 57 58}