Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/typeahead/HeraldRuleDatasource.php
Show All 16 Lines | final class HeraldRuleDatasource | ||||
public function loadResults() { | public function loadResults() { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$raw_query = $this->getRawQuery(); | $raw_query = $this->getRawQuery(); | ||||
$query = id(new HeraldRuleQuery()) | $query = id(new HeraldRuleQuery()) | ||||
->setViewer($viewer); | ->setViewer($viewer); | ||||
if (preg_match('/^[hH]\d+\z/', $raw_query)) { | if (($raw_query !== null) && preg_match('/^[hH]\d+\z/', $raw_query)) { | ||||
$id = trim($raw_query, 'hH'); | $id = trim($raw_query, 'hH'); | ||||
$id = (int)$id; | $id = (int)$id; | ||||
$query->withIDs(array($id)); | $query->withIDs(array($id)); | ||||
} else { | } else { | ||||
$query->withDatasourceQuery($raw_query); | $query->withDatasourceQuery($raw_query); | ||||
} | } | ||||
$rules = $query->execute(); | $rules = $query->execute(); | ||||
Show All 24 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0