Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82483434
ReleephFieldSelector.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
Wed, Sep 11, 16:38
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Sep 13, 16:38 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
20702629
Attached To
rPH Phabricator
ReleephFieldSelector.php
View Options
<?php
abstract
class
ReleephFieldSelector
{
final
public
function
__construct
()
{
// <empty>
}
abstract
public
function
getFieldSpecifications
();
public
function
sortFieldsForCommitMessage
(
array
$fields
)
{
assert_instances_of
(
$fields
,
'ReleephFieldSpecification'
);
return
$fields
;
}
protected
static
function
selectFields
(
array
$fields
,
array
$classes
)
{
assert_instances_of
(
$fields
,
'ReleephFieldSpecification'
);
$map
=
array
();
foreach
(
$fields
as
$field
)
{
$map
[
get_class
(
$field
)]
=
$field
;
}
$result
=
array
();
foreach
(
$classes
as
$class
)
{
$field
=
idx
(
$map
,
$class
);
if
(!
$field
)
{
throw
new
Exception
(
pht
(
"Tried to select a in instance of '%s' but that field "
.
"is not configured for this project!"
,
$class
));
}
if
(
idx
(
$result
,
$class
))
{
throw
new
Exception
(
pht
(
"You have asked to select the field '%s' more than once!"
,
$class
));
}
$result
[
$class
]
=
$field
;
}
return
$result
;
}
}
Event Timeline
Log In to Comment