Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94006490
ReleephProjectInfoConduitAPIMethod.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
Tue, Dec 3, 05:00
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Dec 5, 05:00 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22703625
Attached To
rPH Phabricator
ReleephProjectInfoConduitAPIMethod.php
View Options
<?php
final
class
ReleephProjectInfoConduitAPIMethod
extends
ReleephConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'releeph.projectinfo'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Fetch information about all Releeph projects '
.
'for a given Arcanist project.'
);
}
protected
function
defineParamTypes
()
{
return
array
(
'arcProjectName'
=>
'optional string'
,
);
}
protected
function
defineReturnType
()
{
return
'dict<string, wild>'
;
}
protected
function
defineErrorTypes
()
{
return
array
(
'ERR_UNKNOWN_ARC'
=>
pht
(
"The given Arcanist project name doesn't exist in the "
.
"installation of Phabricator you are accessing."
),
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$arc_project_name
=
$request
->
getValue
(
'arcProjectName'
);
if
(
$arc_project_name
)
{
$arc_project
=
id
(
new
PhabricatorRepositoryArcanistProject
())
->
loadOneWhere
(
'name = %s'
,
$arc_project_name
);
if
(!
$arc_project
)
{
throw
id
(
new
ConduitException
(
'ERR_UNKNOWN_ARC'
))
->
setErrorDescription
(
pht
(
"Unknown Arcanist project '%s': "
.
"are you using the correct Conduit URI?"
,
$arc_project_name
));
}
$releeph_projects
=
id
(
new
ReleephProject
())
->
loadAllWhere
(
'arcanistProjectID = %d'
,
$arc_project
->
getID
());
}
else
{
$releeph_projects
=
id
(
new
ReleephProject
())->
loadAll
();
}
$releeph_projects
=
mfilter
(
$releeph_projects
,
'getIsActive'
);
$result
=
array
();
foreach
(
$releeph_projects
as
$releeph_project
)
{
$selector
=
$releeph_project
->
getReleephFieldSelector
();
$fields
=
$selector
->
getFieldSpecifications
();
$fields_info
=
array
();
foreach
(
$fields
as
$field
)
{
$field
->
setReleephProject
(
$releeph_project
);
if
(
$field
->
isEditable
())
{
$key
=
$field
->
getKeyForConduit
();
$fields_info
[
$key
]
=
array
(
'class'
=>
get_class
(
$field
),
'name'
=>
$field
->
getName
(),
'key'
=>
$key
,
'arcHelp'
=>
$field
->
renderHelpForArcanist
(),
);
}
}
$releeph_branches
=
mfilter
(
id
(
new
ReleephBranch
())
->
loadAllWhere
(
'releephProjectID = %d'
,
$releeph_project
->
getID
()),
'getIsActive'
);
$releeph_branches_struct
=
array
();
foreach
(
$releeph_branches
as
$branch
)
{
$releeph_branches_struct
[]
=
array
(
'branchName'
=>
$branch
->
getName
(),
'projectName'
=>
$releeph_project
->
getName
(),
'projectPHID'
=>
$releeph_project
->
getPHID
(),
'branchPHID'
=>
$branch
->
getPHID
(),
);
}
$result
[]
=
array
(
'projectName'
=>
$releeph_project
->
getName
(),
'projectPHID'
=>
$releeph_project
->
getPHID
(),
'branches'
=>
$releeph_branches_struct
,
'fields'
=>
$fields_info
,
);
}
return
$result
;
}
}
Event Timeline
Log In to Comment