@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 49 lines 1.1 kB view raw
1<?php 2 3final class PHUISpacesNamespaceContextView extends AphrontView { 4 5 private $object; 6 7 public function setObject($object) { 8 $this->object = $object; 9 return $this; 10 } 11 12 public function getObject() { 13 return $this->object; 14 } 15 16 public function render() { 17 $object = $this->getObject(); 18 19 $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object); 20 if (!$space_phid) { 21 return null; 22 } 23 24 // If the viewer can't see spaces, pretend they don't exist. 25 $viewer = $this->getUser(); 26 if (!PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) { 27 return null; 28 } 29 30 // If this is the default space, don't show a space label. 31 $default = PhabricatorSpacesNamespaceQuery::getDefaultSpace(); 32 if ($default) { 33 if ($default->getPHID() == $space_phid) { 34 return null; 35 } 36 } 37 38 return phutil_tag( 39 'span', 40 array( 41 'class' => 'spaces-name', 42 ), 43 array( 44 $viewer->renderHandle($space_phid)->setUseShortName(true), 45 ' | ', 46 )); 47 } 48 49}