@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove some callsites to loadViewerHandles()

Summary: Ref T7689. Use the more modern handle load mechanisms in Almanac.

Test Plan:
- Viewed Almanac binding detail page.
- Viewed Almanac device interface list.
- Grepped for other callsites to InterfaceTableView.
- Viewed Almanac binding table.
- Grepped for other callsites to BindingTableView.
- Viewed Alamanc service table.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7689

Differential Revision: https://secure.phabricator.com/D12340

+21 -57
+3 -10
src/applications/almanac/controller/AlmanacBindingViewController.php
··· 73 73 $properties = id(new PHUIPropertyListView()) 74 74 ->setUser($viewer); 75 75 76 - $handles = $this->loadViewerHandles( 77 - array( 78 - $binding->getServicePHID(), 79 - $binding->getDevicePHID(), 80 - $binding->getInterface()->getNetworkPHID(), 81 - )); 82 - 83 76 $properties->addProperty( 84 77 pht('Service'), 85 - $handles[$binding->getServicePHID()]->renderLink()); 78 + $viewer->renderHandle($binding->getServicePHID())); 86 79 87 80 $properties->addProperty( 88 81 pht('Device'), 89 - $handles[$binding->getDevicePHID()]->renderLink()); 82 + $viewer->renderHandle($binding->getDevicePHID())); 90 83 91 84 $properties->addProperty( 92 85 pht('Network'), 93 - $handles[$binding->getInterface()->getNetworkPHID()]->renderLink()); 86 + $viewer->renderHandle($binding->getInterface()->getNetworkPHID())); 94 87 95 88 $properties->addProperty( 96 89 pht('Interface'),
+3 -11
src/applications/almanac/controller/AlmanacDeviceViewController.php
··· 119 119 ->withDevicePHIDs(array($device->getPHID())) 120 120 ->execute(); 121 121 122 - $phids = array(); 123 - foreach ($interfaces as $interface) { 124 - $phids[] = $interface->getNetworkPHID(); 125 - $phids[] = $interface->getDevicePHID(); 126 - } 127 - $handles = $this->loadViewerHandles($phids); 128 - 129 122 $table = id(new AlmanacInterfaceTableView()) 130 123 ->setUser($viewer) 131 124 ->setInterfaces($interfaces) 132 - ->setHandles($handles) 133 125 ->setCanEdit($can_edit); 134 126 135 127 $header = id(new PHUIHeaderView()) ··· 214 206 } 215 207 216 208 private function buildServicesTable(AlmanacDevice $device) { 209 + $viewer = $this->getViewer(); 217 210 218 211 // NOTE: We're loading all services so we can show hidden, locked services. 219 212 // In general, we let you know about all the things the device is bound to, ··· 226 219 ->withDevicePHIDs(array($device->getPHID())) 227 220 ->execute(); 228 221 229 - $handles = $this->loadViewerHandles(mpull($services, 'getPHID')); 222 + $handles = $viewer->loadHandles(mpull($services, 'getPHID')); 230 223 231 224 $icon_lock = id(new PHUIIconView()) 232 225 ->setIconFont('fa-lock'); 233 226 234 227 $rows = array(); 235 228 foreach ($services as $service) { 236 - $handle = $handles[$service->getPHID()]; 237 229 $rows[] = array( 238 230 ($service->getIsLocked() 239 231 ? $icon_lock 240 232 : null), 241 - $handle->renderLink(), 233 + $handles->renderHandle($service->getPHID()), 242 234 ); 243 235 } 244 236
+1 -10
src/applications/almanac/controller/AlmanacServiceViewController.php
··· 120 120 ->withServicePHIDs(array($service->getPHID())) 121 121 ->execute(); 122 122 123 - $phids = array(); 124 - foreach ($bindings as $binding) { 125 - $phids[] = $binding->getServicePHID(); 126 - $phids[] = $binding->getDevicePHID(); 127 - $phids[] = $binding->getInterface()->getNetworkPHID(); 128 - } 129 - $handles = $this->loadViewerHandles($phids); 130 - 131 123 $table = id(new AlmanacBindingTableView()) 132 124 ->setNoDataString( 133 125 pht('This service has not been bound to any device interfaces yet.')) 134 126 ->setUser($viewer) 135 - ->setBindings($bindings) 136 - ->setHandles($handles); 127 + ->setBindings($bindings); 137 128 138 129 $header = id(new PHUIHeaderView()) 139 130 ->setHeader(pht('Service Bindings'))
+11 -14
src/applications/almanac/view/AlmanacBindingTableView.php
··· 3 3 final class AlmanacBindingTableView extends AphrontView { 4 4 5 5 private $bindings; 6 - private $handles; 7 6 private $noDataString; 8 7 9 8 public function setNoDataString($no_data_string) { ··· 15 14 return $this->noDataString; 16 15 } 17 16 18 - public function setHandles(array $handles) { 19 - $this->handles = $handles; 20 - return $this; 21 - } 22 - 23 - public function getHandles() { 24 - return $this->handles; 25 - } 26 - 27 17 public function setBindings(array $bindings) { 28 18 $this->bindings = $bindings; 29 19 return $this; ··· 35 25 36 26 public function render() { 37 27 $bindings = $this->getBindings(); 38 - $handles = $this->getHandles(); 39 28 $viewer = $this->getUser(); 40 29 30 + $phids = array(); 31 + foreach ($bindings as $binding) { 32 + $phids[] = $binding->getServicePHID(); 33 + $phids[] = $binding->getDevicePHID(); 34 + $phids[] = $binding->getInterface()->getNetworkPHID(); 35 + } 36 + $handles = $viewer->loadHandles($phids); 37 + 41 38 $rows = array(); 42 39 foreach ($bindings as $binding) { 43 40 $addr = $binding->getInterface()->getAddress(); ··· 45 42 46 43 $rows[] = array( 47 44 $binding->getID(), 48 - $handles[$binding->getServicePHID()]->renderLink(), 49 - $handles[$binding->getDevicePHID()]->renderLink(), 50 - $handles[$binding->getInterface()->getNetworkPHID()]->renderLink(), 45 + $handles->renderHandle($binding->getServicePHID()), 46 + $handles->renderHandle($binding->getDevicePHID()), 47 + $handles->renderHandle($binding->getInterface()->getNetworkPHID()), 51 48 $binding->getInterface()->renderDisplayAddress(), 52 49 phutil_tag( 53 50 'a',
+3 -12
src/applications/almanac/view/AlmanacInterfaceTableView.php
··· 3 3 final class AlmanacInterfaceTableView extends AphrontView { 4 4 5 5 private $interfaces; 6 - private $handles; 7 6 private $canEdit; 8 7 9 - public function setHandles(array $handles) { 10 - $this->handles = $handles; 11 - return $this; 12 - } 13 - 14 - public function getHandles() { 15 - return $this->handles; 16 - } 17 - 18 8 public function setInterfaces(array $interfaces) { 19 9 $this->interfaces = $interfaces; 20 10 return $this; ··· 35 25 36 26 public function render() { 37 27 $interfaces = $this->getInterfaces(); 38 - $handles = $this->getHandles(); 39 28 $viewer = $this->getUser(); 40 29 41 30 if ($this->getCanEdit()) { ··· 44 33 $button_class = 'small grey button disabled'; 45 34 } 46 35 36 + $handles = $viewer->loadHandles(mpull($interfaces, 'getNetworkPHID')); 37 + 47 38 $rows = array(); 48 39 foreach ($interfaces as $interface) { 49 40 $rows[] = array( 50 41 $interface->getID(), 51 - $handles[$interface->getNetworkPHID()]->renderLink(), 42 + $handles->renderHandle($interface->getNetworkPHID()), 52 43 $interface->getAddress(), 53 44 $interface->getPort(), 54 45 phutil_tag(