Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101278652
PhabricatorObjectStatus.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
Fri, Feb 7, 10:35
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 9, 10:35 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
24129219
Attached To
rPH Phabricator
PhabricatorObjectStatus.php
View Options
<?php
abstract
class
PhabricatorObjectStatus
extends
Phobject
{
private
$key
;
private
$properties
;
protected
function
__construct
(
$key
=
null
,
array
$properties
=
array
())
{
$this
->
key
=
$key
;
$this
->
properties
=
$properties
;
}
protected
function
getStatusProperty
(
$key
)
{
if
(!
array_key_exists
(
$key
,
$this
->
properties
))
{
throw
new
Exception
(
pht
(
'Attempting to access unknown status property ("%s").'
,
$key
));
}
return
$this
->
properties
[
$key
];
}
public
function
getKey
()
{
return
$this
->
key
;
}
public
function
getIcon
()
{
return
$this
->
getStatusProperty
(
'icon'
);
}
public
function
getDisplayName
()
{
return
$this
->
getStatusProperty
(
'name'
);
}
public
function
getColor
()
{
return
$this
->
getStatusProperty
(
'color'
);
}
protected
function
getStatusSpecification
(
$status
)
{
$map
=
self
::
getStatusSpecifications
();
if
(
isset
(
$map
[
$status
]))
{
return
$map
[
$status
];
}
return
array
(
'key'
=>
$status
,
'name'
=>
pht
(
'Unknown ("%s")'
,
$status
),
'icon'
=>
'fa-question-circle'
,
'color'
=>
'indigo'
,
)
+
$this
->
newUnknownStatusSpecification
(
$status
);
}
protected
function
getStatusSpecifications
()
{
$map
=
$this
->
newStatusSpecifications
();
$result
=
array
();
foreach
(
$map
as
$item
)
{
if
(!
array_key_exists
(
'key'
,
$item
))
{
throw
new
Exception
(
pht
(
'Status specification has no "key".'
));
}
$key
=
$item
[
'key'
];
if
(
isset
(
$result
[
$key
]))
{
throw
new
Exception
(
pht
(
'Multiple status definitions share the same key ("%s").'
,
$key
));
}
$result
[
$key
]
=
$item
;
}
return
$result
;
}
abstract
protected
function
newStatusSpecifications
();
protected
function
newUnknownStatusSpecification
(
$status
)
{
return
array
();
}
}
Event Timeline
Log In to Comment