Changeset View
Changeset View
Standalone View
Standalone View
src/applications/typeahead/storage/PhabricatorTypeaheadResult.php
<?php | <?php | ||||
final class PhabricatorTypeaheadResult { | final class PhabricatorTypeaheadResult { | ||||
private $name; | private $name; | ||||
private $uri; | private $uri; | ||||
private $phid; | private $phid; | ||||
private $priorityString; | private $priorityString; | ||||
private $displayName; | private $displayName; | ||||
private $displayType; | private $displayType; | ||||
private $imageURI; | private $imageURI; | ||||
private $priorityType; | private $priorityType; | ||||
private $imageSprite; | private $imageSprite; | ||||
private $icon; | private $icon; | ||||
private $closed; | private $closed; | ||||
private $unique; | |||||
public function setIcon($icon) { | public function setIcon($icon) { | ||||
$this->icon = $icon; | $this->icon = $icon; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setName($name) { | public function setName($name) { | ||||
$this->name = $name; | $this->name = $name; | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | final class PhabricatorTypeaheadResult { | ||||
public function getIcon() { | public function getIcon() { | ||||
return nonempty($this->icon, $this->getDefaultIcon()); | return nonempty($this->icon, $this->getDefaultIcon()); | ||||
} | } | ||||
public function getPHID() { | public function getPHID() { | ||||
return $this->phid; | return $this->phid; | ||||
} | } | ||||
public function setUnique($unique) { | |||||
$this->unique = $unique; | |||||
return $this; | |||||
} | |||||
public function getSortKey() { | public function getSortKey() { | ||||
return phutil_utf8_strtolower($this->getName()); | // Put unique results (special parameter functions) ahead of other | ||||
// results. | |||||
if ($this->unique) { | |||||
$prefix = 'A'; | |||||
} else { | |||||
$prefix = 'B'; | |||||
} | |||||
return $prefix.phutil_utf8_strtolower($this->getName()); | |||||
} | } | ||||
public function getWireFormat() { | public function getWireFormat() { | ||||
$data = array( | $data = array( | ||||
$this->name, | $this->name, | ||||
$this->uri ? (string)$this->uri : null, | $this->uri ? (string)$this->uri : null, | ||||
$this->phid, | $this->phid, | ||||
$this->priorityString, | $this->priorityString, | ||||
$this->displayName, | $this->displayName, | ||||
$this->displayType, | $this->displayType, | ||||
$this->imageURI ? (string)$this->imageURI : null, | $this->imageURI ? (string)$this->imageURI : null, | ||||
$this->priorityType, | $this->priorityType, | ||||
$this->getIcon(), | $this->getIcon(), | ||||
$this->closed, | $this->closed, | ||||
$this->imageSprite ? (string)$this->imageSprite : null, | $this->imageSprite ? (string)$this->imageSprite : null, | ||||
$this->unique ? 1 : null, | |||||
); | ); | ||||
while (end($data) === null) { | while (end($data) === null) { | ||||
array_pop($data); | array_pop($data); | ||||
} | } | ||||
return $data; | return $data; | ||||
} | } | ||||
/** | /** | ||||
Show All 28 Lines |