Changeset View
Changeset View
Standalone View
Standalone View
src/view/widget/hovercard/PhabricatorHovercardView.php
Show All 11 Lines | final class PhabricatorHovercardView extends AphrontView { | ||||
private $handle; | private $handle; | ||||
private $title = array(); | private $title = array(); | ||||
private $detail; | private $detail; | ||||
private $tags = array(); | private $tags = array(); | ||||
private $fields = array(); | private $fields = array(); | ||||
private $actions = array(); | private $actions = array(); | ||||
private $color = 'lightblue'; | |||||
public function setObjectHandle(PhabricatorObjectHandle $handle) { | public function setObjectHandle(PhabricatorObjectHandle $handle) { | ||||
$this->handle = $handle; | $this->handle = $handle; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setTitle($title) { | public function setTitle($title) { | ||||
$this->title = $title; | $this->title = $title; | ||||
return $this; | return $this; | ||||
Show All 21 Lines | public function addAction($label, $uri, $workflow = false) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function addTag(PHUITagView $tag) { | public function addTag(PHUITagView $tag) { | ||||
$this->tags[] = $tag; | $this->tags[] = $tag; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setColor($color) { | |||||
$this->color = $color; | |||||
return $this; | |||||
} | |||||
public function render() { | public function render() { | ||||
if (!$this->handle) { | if (!$this->handle) { | ||||
throw new PhutilInvalidStateException('setObjectHandle'); | throw new PhutilInvalidStateException('setObjectHandle'); | ||||
} | } | ||||
$handle = $this->handle; | $handle = $this->handle; | ||||
require_celerity_resource('phabricator-hovercard-view-css'); | require_celerity_resource('phabricator-hovercard-view-css'); | ||||
$title = pht('%s: %s', | $title = pht('%s: %s', | ||||
$handle->getTypeName(), | $handle->getTypeName(), | ||||
$this->title ? $this->title : $handle->getName()); | $this->title ? $this->title : $handle->getName()); | ||||
$header = new PHUIHeaderView(); | $header = new PHUIHeaderView(); | ||||
$header->setHeaderColor($this->color); | |||||
$header->setHeader($title); | $header->setHeader($title); | ||||
if ($this->tags) { | if ($this->tags) { | ||||
foreach ($this->tags as $tag) { | foreach ($this->tags as $tag) { | ||||
$header->addTag($tag); | $header->addTag($tag); | ||||
} | } | ||||
} | } | ||||
$body = array(); | $body = array(); | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |