Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F548033
ProjectCreateConduitAPIMethod.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ProjectCreateConduitAPIMethod.php
View Options
<?php
final
class
ProjectCreateConduitAPIMethod
extends
ProjectConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'project.create'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Create a project.'
);
}
public
function
getMethodStatus
()
{
return
self
::
METHOD_STATUS_FROZEN
;
}
public
function
getMethodStatusDescription
()
{
return
pht
(
'This method is frozen and will eventually be deprecated. New code '
.
'should use "project.edit" instead.'
);
}
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
=
PhabricatorProjectNameTransaction
::
TRANSACTIONTYPE
;
$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
(
PhabricatorProjectIconTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
$request
->
getValue
(
'icon'
));
}
if
(
$request
->
getValue
(
'color'
))
{
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
PhabricatorProjectColorTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
$request
->
getValue
(
'color'
));
}
if
(
$request
->
getValue
(
'tags'
))
{
$xactions
[]
=
id
(
new
PhabricatorProjectTransaction
())
->
setTransactionType
(
PhabricatorProjectSlugsTransaction
::
TRANSACTIONTYPE
)
->
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
)
->
setContentSource
(
$request
->
newContentSource
());
$editor
->
applyTransactions
(
$project
,
$xactions
);
return
$this
->
buildProjectInfoDictionary
(
$project
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 1:42 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
119724
Default Alt Text
ProjectCreateConduitAPIMethod.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment