Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91646945
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
Wed, Nov 13, 01:36
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Nov 15, 01:36 (2 d)
Engine
blob
Format
Raw Data
Handle
22293165
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