Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F548241
PhabricatorObjectStatus.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
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
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:46 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
102397
Default Alt Text
PhabricatorObjectStatus.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment