Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80900594
ProjectCreateConduitAPIMethod.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, Sep 3, 04:06
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Sep 5, 04:06 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
20458704
Attached To
rPH Phabricator
ProjectCreateConduitAPIMethod.php
View Options
<?php
final
class
ProjectCreateConduitAPIMethod
extends
ProjectConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'project.create'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Create a project.'
);
}
protected
function
defineParamTypes
()
{
return
array
(
'name'
=>
'required string'
,
'members'
=>
'optional list<phid>'
,
'icon'
=>
'optional string'
,
'color'
=>
'optional string'
,
'tags'
=>
'optional list<string>'
,
);
}
protected
function
defineReturnType
()
{
return
'dict'
;
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$user
=
$request
->
getUser
();
$this
->
requireApplicationCapability
(
ProjectCreateProjectsCapability
::
CAPABILITY
,
$user
);
$project
=
PhabricatorProject
::
initializeNewProject
(
$user
);
$type_name
=
PhabricatorProjectTransaction
::
TYPE_NAME
;
$members
=
$request
->
getValue
(
'members'
);
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
$type_name
)
->
setNewValue
(
$request
->
getValue
(
'name'
));
if
(
$request
->
getValue
(
'icon'
))
{
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
PhabricatorProjectTransaction
::
TYPE_ICON
)
->
setNewValue
(
$request
->
getValue
(
'icon'
));
}
if
(
$request
->
getValue
(
'color'
))
{
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
PhabricatorProjectTransaction
::
TYPE_COLOR
)
->
setNewValue
(
$request
->
getValue
(
'color'
));
}
if
(
$request
->
getValue
(
'tags'
))
{
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
PhabricatorProjectTransaction
::
TYPE_SLUGS
)
->
setNewValue
(
$request
->
getValue
(
'tags'
));
}
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_EDGE
)
->
setMetadataValue
(
'edge:type'
,
PhabricatorProjectProjectHasMemberEdgeType
::
EDGECONST
)
->
setNewValue
(
array
(
'+'
=>
array_fuse
(
$members
),
));
$editor
=
id
(
new
PhabricatorProjectTransactionEditor
())
->
setActor
(
$user
)
->
setContinueOnNoEffect
(
true
)
->
setContentSourceFromConduitRequest
(
$request
);
$editor
->
applyTransactions
(
$project
,
$xactions
);
return
$this
->
buildProjectInfoDictionary
(
$project
);
}
}
Event Timeline
Log In to Comment