diff --git a/src/applications/almanac/controller/AlmanacBindingViewController.php b/src/applications/almanac/controller/AlmanacBindingViewController.php --- a/src/applications/almanac/controller/AlmanacBindingViewController.php +++ b/src/applications/almanac/controller/AlmanacBindingViewController.php @@ -73,24 +73,17 @@ $properties = id(new PHUIPropertyListView()) ->setUser($viewer); - $handles = $this->loadViewerHandles( - array( - $binding->getServicePHID(), - $binding->getDevicePHID(), - $binding->getInterface()->getNetworkPHID(), - )); - $properties->addProperty( pht('Service'), - $handles[$binding->getServicePHID()]->renderLink()); + $viewer->renderHandle($binding->getServicePHID())); $properties->addProperty( pht('Device'), - $handles[$binding->getDevicePHID()]->renderLink()); + $viewer->renderHandle($binding->getDevicePHID())); $properties->addProperty( pht('Network'), - $handles[$binding->getInterface()->getNetworkPHID()]->renderLink()); + $viewer->renderHandle($binding->getInterface()->getNetworkPHID())); $properties->addProperty( pht('Interface'), diff --git a/src/applications/almanac/controller/AlmanacDeviceViewController.php b/src/applications/almanac/controller/AlmanacDeviceViewController.php --- a/src/applications/almanac/controller/AlmanacDeviceViewController.php +++ b/src/applications/almanac/controller/AlmanacDeviceViewController.php @@ -119,17 +119,9 @@ ->withDevicePHIDs(array($device->getPHID())) ->execute(); - $phids = array(); - foreach ($interfaces as $interface) { - $phids[] = $interface->getNetworkPHID(); - $phids[] = $interface->getDevicePHID(); - } - $handles = $this->loadViewerHandles($phids); - $table = id(new AlmanacInterfaceTableView()) ->setUser($viewer) ->setInterfaces($interfaces) - ->setHandles($handles) ->setCanEdit($can_edit); $header = id(new PHUIHeaderView()) @@ -214,6 +206,7 @@ } private function buildServicesTable(AlmanacDevice $device) { + $viewer = $this->getViewer(); // NOTE: We're loading all services so we can show hidden, locked services. // In general, we let you know about all the things the device is bound to, @@ -226,19 +219,18 @@ ->withDevicePHIDs(array($device->getPHID())) ->execute(); - $handles = $this->loadViewerHandles(mpull($services, 'getPHID')); + $handles = $viewer->loadHandles(mpull($services, 'getPHID')); $icon_lock = id(new PHUIIconView()) ->setIconFont('fa-lock'); $rows = array(); foreach ($services as $service) { - $handle = $handles[$service->getPHID()]; $rows[] = array( ($service->getIsLocked() ? $icon_lock : null), - $handle->renderLink(), + $handles->renderHandle($service->getPHID()), ); } diff --git a/src/applications/almanac/controller/AlmanacServiceViewController.php b/src/applications/almanac/controller/AlmanacServiceViewController.php --- a/src/applications/almanac/controller/AlmanacServiceViewController.php +++ b/src/applications/almanac/controller/AlmanacServiceViewController.php @@ -120,20 +120,11 @@ ->withServicePHIDs(array($service->getPHID())) ->execute(); - $phids = array(); - foreach ($bindings as $binding) { - $phids[] = $binding->getServicePHID(); - $phids[] = $binding->getDevicePHID(); - $phids[] = $binding->getInterface()->getNetworkPHID(); - } - $handles = $this->loadViewerHandles($phids); - $table = id(new AlmanacBindingTableView()) ->setNoDataString( pht('This service has not been bound to any device interfaces yet.')) ->setUser($viewer) - ->setBindings($bindings) - ->setHandles($handles); + ->setBindings($bindings); $header = id(new PHUIHeaderView()) ->setHeader(pht('Service Bindings')) diff --git a/src/applications/almanac/view/AlmanacBindingTableView.php b/src/applications/almanac/view/AlmanacBindingTableView.php --- a/src/applications/almanac/view/AlmanacBindingTableView.php +++ b/src/applications/almanac/view/AlmanacBindingTableView.php @@ -3,7 +3,6 @@ final class AlmanacBindingTableView extends AphrontView { private $bindings; - private $handles; private $noDataString; public function setNoDataString($no_data_string) { @@ -15,15 +14,6 @@ return $this->noDataString; } - public function setHandles(array $handles) { - $this->handles = $handles; - return $this; - } - - public function getHandles() { - return $this->handles; - } - public function setBindings(array $bindings) { $this->bindings = $bindings; return $this; @@ -35,9 +25,16 @@ public function render() { $bindings = $this->getBindings(); - $handles = $this->getHandles(); $viewer = $this->getUser(); + $phids = array(); + foreach ($bindings as $binding) { + $phids[] = $binding->getServicePHID(); + $phids[] = $binding->getDevicePHID(); + $phids[] = $binding->getInterface()->getNetworkPHID(); + } + $handles = $viewer->loadHandles($phids); + $rows = array(); foreach ($bindings as $binding) { $addr = $binding->getInterface()->getAddress(); @@ -45,9 +42,9 @@ $rows[] = array( $binding->getID(), - $handles[$binding->getServicePHID()]->renderLink(), - $handles[$binding->getDevicePHID()]->renderLink(), - $handles[$binding->getInterface()->getNetworkPHID()]->renderLink(), + $handles->renderHandle($binding->getServicePHID()), + $handles->renderHandle($binding->getDevicePHID()), + $handles->renderHandle($binding->getInterface()->getNetworkPHID()), $binding->getInterface()->renderDisplayAddress(), phutil_tag( 'a', diff --git a/src/applications/almanac/view/AlmanacInterfaceTableView.php b/src/applications/almanac/view/AlmanacInterfaceTableView.php --- a/src/applications/almanac/view/AlmanacInterfaceTableView.php +++ b/src/applications/almanac/view/AlmanacInterfaceTableView.php @@ -3,18 +3,8 @@ final class AlmanacInterfaceTableView extends AphrontView { private $interfaces; - private $handles; private $canEdit; - public function setHandles(array $handles) { - $this->handles = $handles; - return $this; - } - - public function getHandles() { - return $this->handles; - } - public function setInterfaces(array $interfaces) { $this->interfaces = $interfaces; return $this; @@ -35,7 +25,6 @@ public function render() { $interfaces = $this->getInterfaces(); - $handles = $this->getHandles(); $viewer = $this->getUser(); if ($this->getCanEdit()) { @@ -44,11 +33,13 @@ $button_class = 'small grey button disabled'; } + $handles = $viewer->loadHandles(mpull($interfaces, 'getNetworkPHID')); + $rows = array(); foreach ($interfaces as $interface) { $rows[] = array( $interface->getID(), - $handles[$interface->getNetworkPHID()]->renderLink(), + $handles->renderHandle($interface->getNetworkPHID()), $interface->getAddress(), $interface->getPort(), phutil_tag(