[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorSearchDocumentQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $savedQuery; 7 8 public function withSavedQuery(PhabricatorSavedQuery $query) { 9 $this->savedQuery = $query; 10 return $this; 11 } 12 13 protected function loadPage() { 14 $phids = $this->loadDocumentPHIDsWithoutPolicyChecks(); 15 16 $handles = id(new PhabricatorHandleQuery()) 17 ->setViewer($this->getViewer()) 18 ->withPHIDs($phids) 19 ->execute(); 20 21 // Retain engine order. 22 $handles = array_select_keys($handles, $phids); 23 24 return $handles; 25 } 26 27 protected function willFilterPage(array $handles) { 28 // NOTE: This is used by the object selector dialog to exclude the object 29 // you're looking at, so that, e.g., a task can't be set as a dependency 30 // of itself in the UI. 31 32 // TODO: Remove this after object selection moves to ApplicationSearch. 33 34 $exclude = array(); 35 if ($this->savedQuery) { 36 $exclude_phids = $this->savedQuery->getParameter('excludePHIDs', array()); 37 $exclude = array_fuse($exclude_phids); 38 } 39 40 foreach ($handles as $key => $handle) { 41 if (!$handle->isComplete()) { 42 unset($handles[$key]); 43 continue; 44 } 45 if ($handle->getPolicyFiltered()) { 46 unset($handles[$key]); 47 continue; 48 } 49 if (isset($exclude[$handle->getPHID()])) { 50 unset($handles[$key]); 51 continue; 52 } 53 } 54 55 return $handles; 56 } 57 58 public function loadDocumentPHIDsWithoutPolicyChecks() { 59 $query = id(clone($this->savedQuery)) 60 ->setParameter('offset', $this->getOffset()) 61 ->setParameter('limit', $this->getRawResultLimit()); 62 63 $engine = PhabricatorSearchEngineSelector::newSelector()->newEngine(); 64 65 return $engine->executeSearch($query); 66 } 67 68 public function getQueryApplicationClass() { 69 return 'PhabricatorSearchApplication'; 70 } 71 72 protected function getPagingValue($result) { 73 throw new Exception( 74 pht( 75 'This query does not support cursor paging; it must be offset '. 76 'paged.')); 77 } 78 79 protected function nextPage(array $page) { 80 $this->setOffset($this->getOffset() + count($page)); 81 return $this; 82 } 83 84 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |