Changeset View
Changeset View
Standalone View
Standalone View
src/applications/almanac/view/AlmanacInterfaceTableView.php
<?php | <?php | ||||
final class AlmanacInterfaceTableView extends AphrontView { | final class AlmanacInterfaceTableView extends AphrontView { | ||||
private $interfaces; | private $interfaces; | ||||
private $handles; | |||||
private $canEdit; | private $canEdit; | ||||
public function setHandles(array $handles) { | |||||
$this->handles = $handles; | |||||
return $this; | |||||
} | |||||
public function getHandles() { | |||||
return $this->handles; | |||||
} | |||||
public function setInterfaces(array $interfaces) { | public function setInterfaces(array $interfaces) { | ||||
$this->interfaces = $interfaces; | $this->interfaces = $interfaces; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getInterfaces() { | public function getInterfaces() { | ||||
return $this->interfaces; | return $this->interfaces; | ||||
} | } | ||||
public function setCanEdit($can_edit) { | public function setCanEdit($can_edit) { | ||||
$this->canEdit = $can_edit; | $this->canEdit = $can_edit; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCanEdit() { | public function getCanEdit() { | ||||
return $this->canEdit; | return $this->canEdit; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
$interfaces = $this->getInterfaces(); | $interfaces = $this->getInterfaces(); | ||||
$handles = $this->getHandles(); | |||||
$viewer = $this->getUser(); | $viewer = $this->getUser(); | ||||
if ($this->getCanEdit()) { | if ($this->getCanEdit()) { | ||||
$button_class = 'small grey button'; | $button_class = 'small grey button'; | ||||
} else { | } else { | ||||
$button_class = 'small grey button disabled'; | $button_class = 'small grey button disabled'; | ||||
} | } | ||||
$handles = $viewer->loadHandles(mpull($interfaces, 'getNetworkPHID')); | |||||
$rows = array(); | $rows = array(); | ||||
foreach ($interfaces as $interface) { | foreach ($interfaces as $interface) { | ||||
$rows[] = array( | $rows[] = array( | ||||
$interface->getID(), | $interface->getID(), | ||||
$handles[$interface->getNetworkPHID()]->renderLink(), | $handles->renderHandle($interface->getNetworkPHID()), | ||||
$interface->getAddress(), | $interface->getAddress(), | ||||
$interface->getPort(), | $interface->getPort(), | ||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'class' => $button_class, | 'class' => $button_class, | ||||
'href' => '/almanac/interface/edit/'.$interface->getID().'/', | 'href' => '/almanac/interface/edit/'.$interface->getID().'/', | ||||
), | ), | ||||
Show All 26 Lines |