Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F103304256
PhrictionEditConduitAPIMethod.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
Sat, Mar 1, 00:50
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Mar 3, 00:50 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
24538306
Attached To
rPH Phabricator
PhrictionEditConduitAPIMethod.php
View Options
<?php
final
class
PhrictionEditConduitAPIMethod
extends
PhrictionConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'phriction.edit'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Update a Phriction document.'
);
}
protected
function
defineParamTypes
()
{
return
array
(
'slug'
=>
'required string'
,
'title'
=>
'optional string'
,
'content'
=>
'optional string'
,
'description'
=>
'optional string'
,
);
}
protected
function
defineReturnType
()
{
return
'nonempty dict'
;
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$slug
=
$request
->
getValue
(
'slug'
);
$doc
=
id
(
new
PhrictionDocumentQuery
())
->
setViewer
(
$request
->
getUser
())
->
withSlugs
(
array
(
PhabricatorSlug
::
normalize
(
$slug
)))
->
needContent
(
true
)
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$doc
)
{
throw
new
Exception
(
pht
(
'No such document.'
));
}
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhrictionTransaction
())
->
setTransactionType
(
PhrictionDocumentTitleTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
$request
->
getValue
(
'title'
));
$xactions
[]
=
id
(
new
PhrictionTransaction
())
->
setTransactionType
(
PhrictionDocumentContentTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
$request
->
getValue
(
'content'
));
$editor
=
id
(
new
PhrictionTransactionEditor
())
->
setActor
(
$request
->
getUser
())
->
setContentSource
(
$request
->
newContentSource
())
->
setContinueOnNoEffect
(
true
)
->
setDescription
((
string
)
$request
->
getValue
(
'description'
));
try
{
$editor
->
applyTransactions
(
$doc
,
$xactions
);
}
catch
(
PhabricatorApplicationTransactionValidationException
$ex
)
{
// TODO - some magical hotness via T5873
throw
$ex
;
}
return
$this
->
buildDocumentInfoDictionary
(
$doc
);
}
}
Event Timeline
Log In to Comment