Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / view / phui / PHUITabView.php
blobe50dbcbc4efe62c33914e64d3697e3ae31036222
1 <?php
3 final class PHUITabView extends AphrontTagView {
5 private $icon;
6 private $name;
7 private $key;
8 private $keyLocked;
9 private $contentID;
10 private $color;
12 public function setKey($key) {
13 if ($this->keyLocked) {
14 throw new Exception(
15 pht(
16 'Attempting to change the key of a tab with a locked key ("%s").',
17 $this->key));
20 $this->key = $key;
21 return $this;
24 public function hasKey() {
25 return ($this->key !== null);
28 public function getKey() {
29 if (!$this->hasKey()) {
30 throw new PhutilInvalidStateException('setKey');
33 return $this->key;
36 public function lockKey() {
37 if (!$this->hasKey()) {
38 throw new PhutilInvalidStateException('setKey');
41 $this->keyLocked = true;
43 return $this;
46 public function setName($name) {
47 $this->name = $name;
48 return $this;
51 public function getName() {
52 return $this->name;
55 public function setIcon(PHUIIconView $icon) {
56 $this->icon = $icon;
57 return $this;
60 public function getIcon() {
61 return $this->icon;
64 public function getContentID() {
65 if ($this->contentID === null) {
66 $this->contentID = celerity_generate_unique_node_id();
69 return $this->contentID;
72 public function setColor($color) {
73 $this->color = $color;
74 return $this;
77 public function getColor() {
78 return $this->color;
81 public function newMenuItem() {
82 $item = id(new PHUIListItemView())
83 ->setName($this->getName())
84 ->setKey($this->getKey())
85 ->setType(PHUIListItemView::TYPE_LINK)
86 ->setHref('#')
87 ->addSigil('phui-tab-view')
88 ->setMetadata(
89 array(
90 'tabKey' => $this->getKey(),
91 ));
93 $icon = $this->getIcon();
94 if ($icon) {
95 $item->setIcon($icon->getIconName());
98 $color = $this->getColor();
99 if ($color !== null) {
100 $item->setStatusColor($color);
103 return $item;