Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96177852
DrydockResourceListView.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 23, 12:08
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 12:08 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23138426
Attached To
rPH Phabricator
DrydockResourceListView.php
View Options
<?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
->
setStatusIcon
(
'fa-dot-circle-o yellow'
);
break
;
case
DrydockResourceStatus
::
STATUS_ACTIVE
:
$item
->
setStatusIcon
(
'fa-dot-circle-o green'
);
break
;
case
DrydockResourceStatus
::
STATUS_DESTROYED
:
$item
->
setStatusIcon
(
'fa-times-circle-o black'
);
break
;
default
:
$item
->
setStatusIcon
(
'fa-dot-circle-o red'
);
break
;
}
$view
->
addItem
(
$item
);
}
return
$view
;
}
}
Event Timeline
Log In to Comment