1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-16 20:02:40 +01:00
phorge-phorge/src/applications/drydock/view/DrydockResourceListView.php

50 lines
1.2 KiB
PHP
Raw Normal View History

<?php
final class DrydockResourceListView extends AphrontView {
private $resources;
public function setResources(array $resources) {
assert_instances_of($resources, 'DrydockResource');
$this->resources = $resources;
return $this;
}
public function render() {
$resources = $this->resources;
$viewer = $this->getUser();
$view = new PHUIObjectItemListView();
foreach ($resources as $resource) {
$name = pht('Resource %d', $resource->getID()).': '.$resource->getName();
$item = id(new PHUIObjectItemView())
->setHref('/drydock/resource/'.$resource->getID().'/')
->setHeader($name);
$status = DrydockResourceStatus::getNameForStatus($resource->getStatus());
$item->addAttribute($status);
switch ($resource->getStatus()) {
case DrydockResourceStatus::STATUS_PENDING:
$item->setBarColor('yellow');
break;
case DrydockResourceStatus::STATUS_OPEN:
$item->setBarColor('green');
break;
case DrydockResourceStatus::STATUS_DESTROYED:
$item->setBarColor('black');
break;
default:
$item->setBarColor('red');
break;
}
$view->addItem($item);
}
return $view;
}
}