Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/view/AlmanacBindingTableView.php
<?php | <?php | ||||
final class AlmanacBindingTableView extends AphrontView { | final class AlmanacBindingTableView extends AphrontView { | ||||
private $bindings; | private $bindings; | ||||
private $handles; | |||||
private $noDataString; | private $noDataString; | ||||
public function setNoDataString($no_data_string) { | public function setNoDataString($no_data_string) { | ||||
$this->noDataString = $no_data_string; | $this->noDataString = $no_data_string; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getNoDataString() { | public function getNoDataString() { | ||||
return $this->noDataString; | return $this->noDataString; | ||||
} | } | ||||
public function setHandles(array $handles) { | |||||
$this->handles = $handles; | |||||
return $this; | |||||
} | |||||
public function getHandles() { | |||||
return $this->handles; | |||||
} | |||||
public function setBindings(array $bindings) { | public function setBindings(array $bindings) { | ||||
$this->bindings = $bindings; | $this->bindings = $bindings; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getBindings() { | public function getBindings() { | ||||
return $this->bindings; | return $this->bindings; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
$bindings = $this->getBindings(); | $bindings = $this->getBindings(); | ||||
$handles = $this->getHandles(); | |||||
$viewer = $this->getUser(); | $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(); | $rows = array(); | ||||
foreach ($bindings as $binding) { | foreach ($bindings as $binding) { | ||||
$addr = $binding->getInterface()->getAddress(); | $addr = $binding->getInterface()->getAddress(); | ||||
$port = $binding->getInterface()->getPort(); | $port = $binding->getInterface()->getPort(); | ||||
$rows[] = array( | $rows[] = array( | ||||
$binding->getID(), | $binding->getID(), | ||||
$handles[$binding->getServicePHID()]->renderLink(), | $handles->renderHandle($binding->getServicePHID()), | ||||
$handles[$binding->getDevicePHID()]->renderLink(), | $handles->renderHandle($binding->getDevicePHID()), | ||||
$handles[$binding->getInterface()->getNetworkPHID()]->renderLink(), | $handles->renderHandle($binding->getInterface()->getNetworkPHID()), | ||||
$binding->getInterface()->renderDisplayAddress(), | $binding->getInterface()->renderDisplayAddress(), | ||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'class' => 'small grey button', | 'class' => 'small grey button', | ||||
'href' => '/almanac/binding/'.$binding->getID().'/', | 'href' => '/almanac/binding/'.$binding->getID().'/', | ||||
), | ), | ||||
pht('Details')), | pht('Details')), | ||||
Show All 28 Lines |