3 final class ProjectCreateConduitAPIMethod
extends ProjectConduitAPIMethod
{
5 public function getAPIMethodName() {
6 return 'project.create';
9 public function getMethodDescription() {
10 return pht('Create a project.');
13 public function getMethodStatus() {
14 return self
::METHOD_STATUS_FROZEN
;
17 public function getMethodStatusDescription() {
19 'This method is frozen and will eventually be deprecated. New code '.
20 'should use "project.edit" instead.');
23 protected function defineParamTypes() {
25 'name' => 'required string',
26 'members' => 'optional list<phid>',
27 'icon' => 'optional string',
28 'color' => 'optional string',
29 'tags' => 'optional list<string>',
33 protected function defineReturnType() {
37 protected function execute(ConduitAPIRequest
$request) {
38 $user = $request->getUser();
40 $this->requireApplicationCapability(
41 ProjectCreateProjectsCapability
::CAPABILITY
,
44 $project = PhabricatorProject
::initializeNewProject($user);
45 $type_name = PhabricatorProjectNameTransaction
::TRANSACTIONTYPE
;
46 $members = $request->getValue('members');
49 $xactions[] = id(new PhabricatorProjectTransaction())
50 ->setTransactionType($type_name)
51 ->setNewValue($request->getValue('name'));
53 if ($request->getValue('icon')) {
54 $xactions[] = id(new PhabricatorProjectTransaction())
56 PhabricatorProjectIconTransaction
::TRANSACTIONTYPE
)
57 ->setNewValue($request->getValue('icon'));
60 if ($request->getValue('color')) {
61 $xactions[] = id(new PhabricatorProjectTransaction())
63 PhabricatorProjectColorTransaction
::TRANSACTIONTYPE
)
64 ->setNewValue($request->getValue('color'));
67 if ($request->getValue('tags')) {
68 $xactions[] = id(new PhabricatorProjectTransaction())
70 PhabricatorProjectSlugsTransaction
::TRANSACTIONTYPE
)
71 ->setNewValue($request->getValue('tags'));
74 $xactions[] = id(new PhabricatorProjectTransaction())
75 ->setTransactionType(PhabricatorTransactions
::TYPE_EDGE
)
78 PhabricatorProjectProjectHasMemberEdgeType
::EDGECONST
)
81 '+' => array_fuse($members),
84 $editor = id(new PhabricatorProjectTransactionEditor())
86 ->setContinueOnNoEffect(true)
87 ->setContentSource($request->newContentSource());
89 $editor->applyTransactions($project, $xactions);
91 return $this->buildProjectInfoDictionary($project);