@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 recaptime-dev/main 83 lines 1.9 kB view raw
1<?php 2 3final class PhortuneSubscriptionTableView extends AphrontView { 4 5 private $subscriptions; 6 private $isMerchantView; 7 private $notice; 8 9 public function setSubscriptions(array $subscriptions) { 10 $this->subscriptions = $subscriptions; 11 return $this; 12 } 13 14 public function getSubscriptions() { 15 return $this->subscriptions; 16 } 17 18 public function setIsMerchantView($is_merchant_view) { 19 $this->isMerchantView = $is_merchant_view; 20 return $this; 21 } 22 23 public function getIsMerchantView() { 24 return $this->isMerchantView; 25 } 26 27 public function setNotice($notice) { 28 $this->notice = $notice; 29 return $this; 30 } 31 32 public function render() { 33 return $this->newTableView(); 34 } 35 36 public function newTableView() { 37 $subscriptions = $this->getSubscriptions(); 38 $viewer = $this->getViewer(); 39 40 $phids = mpull($subscriptions, 'getPHID'); 41 $handles = $viewer->loadHandles($phids); 42 43 $rows = array(); 44 $rowc = array(); 45 foreach ($subscriptions as $subscription) { 46 if ($this->getIsMerchantView()) { 47 $uri = $subscription->getMerchantURI(); 48 } else { 49 $uri = $subscription->getURI(); 50 } 51 52 $subscription_link = $handles[$subscription->getPHID()]->renderLink(); 53 $rows[] = array( 54 $subscription->getID(), 55 phutil_tag( 56 'a', 57 array( 58 'href' => $uri, 59 ), 60 $subscription->getSubscriptionFullName()), 61 phabricator_datetime($subscription->getDateCreated(), $viewer), 62 ); 63 } 64 65 $table = id(new AphrontTableView($rows)) 66 ->setNotice($this->notice) 67 ->setHeaders( 68 array( 69 pht('ID'), 70 pht('Name'), 71 pht('Created'), 72 )) 73 ->setColumnClasses( 74 array( 75 '', 76 'wide', 77 'right', 78 )); 79 80 return $table; 81 } 82 83}