Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / tokens / engineextension / PhabricatorTokensCurtainExtension.php
blob1d1ca2551c1d5a538bada98ecc4c90b4507b412f
1 <?php
3 final class PhabricatorTokensCurtainExtension
4 extends PHUICurtainExtension {
6 const EXTENSIONKEY = 'tokens.tokens';
8 public function shouldEnableForObject($object) {
9 return ($object instanceof PhabricatorTokenReceiverInterface);
12 public function getExtensionApplication() {
13 return new PhabricatorTokensApplication();
16 public function buildCurtainPanel($object) {
17 $viewer = $this->getViewer();
19 $tokens_given = id(new PhabricatorTokenGivenQuery())
20 ->setViewer($viewer)
21 ->withObjectPHIDs(array($object->getPHID()))
22 ->execute();
23 if (!$tokens_given) {
24 return null;
27 $author_phids = mpull($tokens_given, 'getAuthorPHID');
28 $handles = $viewer->loadHandles($author_phids);
30 Javelin::initBehavior('phabricator-tooltips');
32 $list = array();
33 foreach ($tokens_given as $token_given) {
34 $token = $token_given->getToken();
36 $aural = javelin_tag(
37 'span',
38 array(
39 'aural' => true,
41 pht(
42 '"%s" token, awarded by %s.',
43 $token->getName(),
44 $handles[$token_given->getAuthorPHID()]->getName()));
46 $list[] = javelin_tag(
47 'span',
48 array(
49 'sigil' => 'has-tooltip',
50 'class' => 'token-icon',
51 'meta' => array(
52 'tip' => $handles[$token_given->getAuthorPHID()]->getName(),
55 array(
56 $aural,
57 $token->renderIcon(),
58 ));
61 return $this->newPanel()
62 ->setHeaderText(pht('Tokens'))
63 ->setOrder(30000)
64 ->appendChild($list);