Differential D16838 Diff 40547 src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
<?php | <?php | ||||
/** | /** | ||||
* @task functions Token Functions | * @task functions Token Functions | ||||
*/ | */ | ||||
abstract class PhabricatorTypeaheadDatasource extends Phobject { | abstract class PhabricatorTypeaheadDatasource extends Phobject { | ||||
private $viewer; | private $viewer; | ||||
private $query; | private $query; | ||||
private $rawQuery; | private $rawQuery; | ||||
private $offset; | private $offset; | ||||
private $limit; | private $limit; | ||||
private $parameters = array(); | private $parameters = array(); | ||||
private $functionStack = array(); | private $functionStack = array(); | ||||
private $isBrowse; | private $isBrowse; | ||||
private $phase = self::PHASE_CONTENT; | |||||
const PHASE_PREFIX = 'prefix'; | |||||
const PHASE_CONTENT = 'content'; | |||||
public function setLimit($limit) { | public function setLimit($limit) { | ||||
$this->limit = $limit; | $this->limit = $limit; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getLimit() { | public function getLimit() { | ||||
return $this->limit; | return $this->limit; | ||||
Show All 17 Lines | public function getViewer() { | ||||
return $this->viewer; | return $this->viewer; | ||||
} | } | ||||
public function setRawQuery($raw_query) { | public function setRawQuery($raw_query) { | ||||
$this->rawQuery = $raw_query; | $this->rawQuery = $raw_query; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPrefixQuery() { | |||||
return phutil_utf8_strtolower($this->getRawQuery()); | |||||
} | |||||
public function getRawQuery() { | public function getRawQuery() { | ||||
return $this->rawQuery; | return $this->rawQuery; | ||||
} | } | ||||
public function setQuery($query) { | public function setQuery($query) { | ||||
$this->query = $query; | $this->query = $query; | ||||
return $this; | return $this; | ||||
} | } | ||||
Show All 19 Lines | public function setIsBrowse($is_browse) { | ||||
$this->isBrowse = $is_browse; | $this->isBrowse = $is_browse; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getIsBrowse() { | public function getIsBrowse() { | ||||
return $this->isBrowse; | return $this->isBrowse; | ||||
} | } | ||||
public function setPhase($phase) { | |||||
$this->phase = $phase; | |||||
return $this; | |||||
} | |||||
public function getPhase() { | |||||
return $this->phase; | |||||
} | |||||
public function getDatasourceURI() { | public function getDatasourceURI() { | ||||
$uri = new PhutilURI('/typeahead/class/'.get_class($this).'/'); | $uri = new PhutilURI('/typeahead/class/'.get_class($this).'/'); | ||||
$uri->setQueryParams($this->parameters); | $uri->setQueryParams($this->parameters); | ||||
return (string)$uri; | return (string)$uri; | ||||
} | } | ||||
public function getBrowseURI() { | public function getBrowseURI() { | ||||
if (!$this->isBrowsable()) { | if (!$this->isBrowsable()) { | ||||
Show All 9 Lines | abstract class PhabricatorTypeaheadDatasource extends Phobject { | ||||
public function getBrowseTitle() { | public function getBrowseTitle() { | ||||
return get_class($this); | return get_class($this); | ||||
} | } | ||||
abstract public function getDatasourceApplicationClass(); | abstract public function getDatasourceApplicationClass(); | ||||
abstract public function loadResults(); | abstract public function loadResults(); | ||||
protected function loadResultsForPhase($phase, $limit) { | |||||
// By default, sources just load all of their results in every phase and | |||||
// rely on filtering at a higher level to sequence phases correctly. | |||||
$this->setLimit($limit); | |||||
return $this->loadResults(); | |||||
} | |||||
protected function didLoadResults(array $results) { | protected function didLoadResults(array $results) { | ||||
return $results; | return $results; | ||||
} | } | ||||
public static function tokenizeString($string) { | public static function tokenizeString($string) { | ||||
$string = phutil_utf8_strtolower($string); | $string = phutil_utf8_strtolower($string); | ||||
$string = trim($string); | $string = trim($string); | ||||
if (!strlen($string)) { | if (!strlen($string)) { | ||||
▲ Show 20 Lines • Show All 387 Lines • Show Last 20 Lines |