Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F17826432
HarbormasterQueryAutotargetsConduitAPIMethod.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
HarbormasterQueryAutotargetsConduitAPIMethod.php
View Options
<?php
final
class
HarbormasterQueryAutotargetsConduitAPIMethod
extends
HarbormasterConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'harbormaster.queryautotargets'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Load or create build autotargets.'
);
}
protected
function
defineParamTypes
()
{
return
array
(
'objectPHID'
=>
'phid'
,
'targetKeys'
=>
'list<string>'
,
);
}
protected
function
defineReturnType
()
{
return
'map<string, phid>'
;
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$viewer
=
$request
->
getUser
();
$phid
=
$request
->
getValue
(
'objectPHID'
);
// NOTE: We use withNames() to let monograms like "D123" work, which makes
// this a little easier to test. Real PHIDs will still work as expected.
$object
=
id
(
new
PhabricatorObjectQuery
())
->
setViewer
(
$viewer
)
->
withNames
(
array
(
$phid
))
->
executeOne
();
if
(!
$object
)
{
throw
new
Exception
(
pht
(
'No such object "%s" exists.'
,
$phid
));
}
if
(!(
$object
instanceof
HarbormasterBuildableInterface
))
{
throw
new
Exception
(
pht
(
'Object "%s" does not implement interface "%s". Autotargets may '
.
'only be queried for buildable objects.'
,
$phid
,
'HarbormasterBuildableInterface'
));
}
$autotargets
=
$request
->
getValue
(
'targetKeys'
,
array
());
if
(
$autotargets
)
{
$targets
=
id
(
new
HarbormasterTargetEngine
())
->
setViewer
(
$viewer
)
->
setObject
(
$object
)
->
setAutoTargetKeys
(
$autotargets
)
->
buildTargets
();
}
else
{
$targets
=
array
();
}
// Reorder the results according to the request order so we can make test
// assertions that subsequent calls return the same results.
$map
=
mpull
(
$targets
,
'getPHID'
);
$map
=
array_select_keys
(
$map
,
$autotargets
);
return
array
(
'targetMap'
=>
$map
,
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Jul 28, 7:17 AM (4 d, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8234319
Default Alt Text
HarbormasterQueryAutotargetsConduitAPIMethod.php (1 KB)
Attached To
Mode
rP Phabricator
Attached
Detach File
Event Timeline
Log In to Comment