Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92816955
WMPolicyQueryConduitAPIMethod.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
Sat, Nov 23, 22:38
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Nov 25, 22:38 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22479200
Attached To
rPH Phabricator
WMPolicyQueryConduitAPIMethod.php
View Options
<?php
class
PolicyQueryConduitAPIMethod
extends
ConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'policy.query'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Execute searches for Policies.'
);
}
protected
function
defineParamTypes
()
{
return
array
(
'phids'
=>
'required ist<phid>'
,
'limit'
=>
'optional int'
,
'offset'
=>
'optional int'
,
);
}
protected
function
defineReturnType
()
{
return
'dict<string, wild>'
;
}
protected
function
defineErrorTypes
()
{
return
array
(
'ERR-INVALID-PARAMETER'
=>
pht
(
'Missing or malformed parameter.'
),
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$phids
=
$request
->
getValue
(
'phids'
);
if
(!
$phids
)
{
throw
id
(
new
ConduitException
(
'ERR-INVALID-PARAMETER'
))
->
setErrorDescription
(
pht
(
"PHIDs required"
));
}
$policies
=
id
(
new
PhabricatorPolicyQuery
())
->
setViewer
(
$request
->
getUser
())
->
withPHIDs
(
$phids
)
->
execute
();
if
(!
$policies
)
{
throw
id
(
new
ConduitException
(
'ERR-INVALID-PARAMETER'
))
->
setErrorDescription
(
pht
(
"Unknown policies: %s"
,
implode
(
', '
,
$phids
)));
}
$result
=
array
();
foreach
(
$policies
as
$phid
=>
$policy
)
{
$type
=
$policy
->
getType
();
$result
[
$phid
]
=
array
(
'phid'
=>
$phid
,
'type'
=>
$type
,
'name'
=>
$policy
->
getName
(),
'shortName'
=>
$policy
->
getShortName
(),
'fullName'
=>
$policy
->
getFullName
(),
'href'
=>
$policy
->
getHref
(),
'workflow'
=>
$policy
->
getWorkflow
(),
'icon'
=>
$policy
->
getIcon
(),
);
if
(
$type
===
PhabricatorPolicyType
::
TYPE_CUSTOM
)
{
$result
[
$phid
][
'default'
]
=
$policy
->
getDefaultAction
();
$result
[
$phid
][
'rules'
]
=
$policy
->
getRules
();
}
}
return
$result
;
}
}
Event Timeline
Log In to Comment