Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90429874
LegalpadDocumentCommentController.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 1, 14:22
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 3, 14:22 (2 d)
Engine
blob
Format
Raw Data
Handle
22072974
Attached To
rPH Phabricator
LegalpadDocumentCommentController.php
View Options
<?php
final
class
LegalpadDocumentCommentController
extends
LegalpadController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
if
(!
$request
->
isFormPost
())
{
return
new
Aphront400Response
();
}
$document
=
id
(
new
LegalpadDocumentQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
needDocumentBodies
(
true
)
->
executeOne
();
if
(!
$document
)
{
return
new
Aphront404Response
();
}
$is_preview
=
$request
->
isPreviewRequest
();
$draft
=
PhabricatorDraft
::
buildFromRequest
(
$request
);
$document_uri
=
$this
->
getApplicationURI
(
'view/'
.
$document
->
getID
());
$comment
=
$request
->
getStr
(
'comment'
);
$xactions
=
array
();
if
(
strlen
(
$comment
))
{
$xactions
[]
=
id
(
new
LegalpadTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_COMMENT
)
->
attachComment
(
id
(
new
LegalpadTransactionComment
())
->
setDocumentID
(
$document
->
getID
())
->
setLineNumber
(
0
)
->
setLineLength
(
0
)
->
setContent
(
$comment
));
}
$editor
=
id
(
new
LegalpadDocumentEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
$request
->
isContinueRequest
())
->
setIsPreview
(
$is_preview
);
try
{
$xactions
=
$editor
->
applyTransactions
(
$document
,
$xactions
);
}
catch
(
PhabricatorApplicationTransactionNoEffectException
$ex
)
{
return
id
(
new
PhabricatorApplicationTransactionNoEffectResponse
())
->
setCancelURI
(
$document_uri
)
->
setException
(
$ex
);
}
if
(
$draft
)
{
$draft
->
replaceOrDelete
();
}
if
(
$request
->
isAjax
()
&&
$is_preview
)
{
return
id
(
new
PhabricatorApplicationTransactionResponse
())
->
setViewer
(
$viewer
)
->
setTransactions
(
$xactions
)
->
setIsPreview
(
$is_preview
);
}
else
{
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$document_uri
);
}
}
}
Event Timeline
Log In to Comment