Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92694515
NuanceCreateItemConduitAPIMethod.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
Fri, Nov 22, 20:40
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 20:40 (2 d)
Engine
blob
Format
Raw Data
Handle
22489049
Attached To
rPH Phabricator
NuanceCreateItemConduitAPIMethod.php
View Options
<?php
final
class
NuanceCreateItemConduitAPIMethod
extends
NuanceConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'nuance.createitem'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Create a new item.'
);
}
public
function
defineParamTypes
()
{
return
array
(
'requestorPHID'
=>
'required string'
,
'sourcePHID'
=>
'required string'
,
'ownerPHID'
=>
'optional string'
,
);
}
public
function
defineReturnType
()
{
return
'nonempty dict'
;
}
public
function
defineErrorTypes
()
{
return
array
(
'ERR-NO-REQUESTOR-PHID'
=>
pht
(
'Items must have a requestor.'
),
'ERR-NO-SOURCE-PHID'
=>
pht
(
'Items must have a source.'
),
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$source_phid
=
$request
->
getValue
(
'sourcePHID'
);
$owner_phid
=
$request
->
getValue
(
'ownerPHID'
);
$requestor_phid
=
$request
->
getValue
(
'requestorPHID'
);
$user
=
$request
->
getUser
();
$item
=
NuanceItem
::
initializeNewItem
(
$user
);
$xactions
=
array
();
if
(
$source_phid
)
{
$xactions
[]
=
id
(
new
NuanceItemTransaction
())
->
setTransactionType
(
NuanceItemTransaction
::
TYPE_SOURCE
)
->
setNewValue
(
$source_phid
);
}
else
{
throw
new
ConduitException
(
'ERR-NO-SOURCE-PHID'
);
}
if
(
$owner_phid
)
{
$xactions
[]
=
id
(
new
NuanceItemTransaction
())
->
setTransactionType
(
NuanceItemTransaction
::
TYPE_OWNER
)
->
setNewValue
(
$owner_phid
);
}
if
(
$requestor_phid
)
{
$xactions
[]
=
id
(
new
NuanceItemTransaction
())
->
setTransactionType
(
NuanceItemTransaction
::
TYPE_REQUESTOR
)
->
setNewValue
(
$requestor_phid
);
}
else
{
throw
new
ConduitException
(
'ERR-NO-REQUESTOR-PHID'
);
}
$source
=
PhabricatorContentSource
::
newFromConduitRequest
(
$request
);
$editor
=
id
(
new
NuanceItemEditor
())
->
setActor
(
$user
)
->
setContentSource
(
$source
)
->
applyTransactions
(
$item
,
$xactions
);
return
$item
->
toDictionary
();
}
}
Event Timeline
Log In to Comment