Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / project / conduit / ProjectCreateConduitAPIMethod.php
blobcbaa006951f3dacf8d0f9a115bb62e47e6229672
1 <?php
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() {
18 return pht(
19 'This method is frozen and will eventually be deprecated. New code '.
20 'should use "project.edit" instead.');
23 protected function defineParamTypes() {
24 return array(
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() {
34 return 'dict';
37 protected function execute(ConduitAPIRequest $request) {
38 $user = $request->getUser();
40 $this->requireApplicationCapability(
41 ProjectCreateProjectsCapability::CAPABILITY,
42 $user);
44 $project = PhabricatorProject::initializeNewProject($user);
45 $type_name = PhabricatorProjectNameTransaction::TRANSACTIONTYPE;
46 $members = $request->getValue('members');
47 $xactions = array();
49 $xactions[] = id(new PhabricatorProjectTransaction())
50 ->setTransactionType($type_name)
51 ->setNewValue($request->getValue('name'));
53 if ($request->getValue('icon')) {
54 $xactions[] = id(new PhabricatorProjectTransaction())
55 ->setTransactionType(
56 PhabricatorProjectIconTransaction::TRANSACTIONTYPE)
57 ->setNewValue($request->getValue('icon'));
60 if ($request->getValue('color')) {
61 $xactions[] = id(new PhabricatorProjectTransaction())
62 ->setTransactionType(
63 PhabricatorProjectColorTransaction::TRANSACTIONTYPE)
64 ->setNewValue($request->getValue('color'));
67 if ($request->getValue('tags')) {
68 $xactions[] = id(new PhabricatorProjectTransaction())
69 ->setTransactionType(
70 PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE)
71 ->setNewValue($request->getValue('tags'));
74 $xactions[] = id(new PhabricatorProjectTransaction())
75 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
76 ->setMetadataValue(
77 'edge:type',
78 PhabricatorProjectProjectHasMemberEdgeType::EDGECONST)
79 ->setNewValue(
80 array(
81 '+' => array_fuse($members),
82 ));
84 $editor = id(new PhabricatorProjectTransactionEditor())
85 ->setActor($user)
86 ->setContinueOnNoEffect(true)
87 ->setContentSource($request->newContentSource());
89 $editor->applyTransactions($project, $xactions);
91 return $this->buildProjectInfoDictionary($project);