diff --git a/src/view/widget/hovercard/PhabricatorHovercardView.php b/src/view/widget/hovercard/PhabricatorHovercardView.php index 86b482fd43..aaa9988b4d 100644 --- a/src/view/widget/hovercard/PhabricatorHovercardView.php +++ b/src/view/widget/hovercard/PhabricatorHovercardView.php @@ -11,6 +11,8 @@ final class PhabricatorHovercardView extends AphrontView { */ private $handle; + private $id; + private $title = array(); private $detail; private $tags = array(); @@ -24,6 +26,11 @@ final class PhabricatorHovercardView extends AphrontView { private $color = 'grey'; + public function setId($id) { + $this->id = $id; + return $this; + } + public function setObjectHandle(PhabricatorObjectHandle $handle) { $this->handle = $handle; return $this; @@ -67,6 +74,10 @@ final class PhabricatorHovercardView extends AphrontView { } public function render() { + if (!$this->handle) { + throw new Exception("Call setObjectHandle() before calling render()!"); + } + $handle = $this->handle; $user = $this->getUser(); @@ -85,7 +96,10 @@ final class PhabricatorHovercardView extends AphrontView { ), array_interleave(' ', $this->tags)); } - $title[] = pht("%s: %s", $handle->getTypeName(), substr($type, 0, 1) . $id); + + $title[] = pht("%s: %s", + $handle->getTypeName(), + $this->title ? $this->title : substr($type, 0, 1) . $id); $body = array(); if ($this->detail) { @@ -163,6 +177,7 @@ final class PhabricatorHovercardView extends AphrontView { return phutil_tag('div', array( 'class' => 'phabricator-hovercard-wrapper', + 'id' => $this->id, ), $hovercard); }