Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112482823
PholioMockCommentController.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, May 10, 21:44
Size
1 KB
Mime Type
text/x-php
Expires
Mon, May 12, 21:44 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
26086284
Attached To
rPH Phabricator
PholioMockCommentController.php
View Options
<?php
/**
* @group pholio
*/
final
class
PholioMockCommentController
extends
PholioController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$mock
=
id
(
new
PholioMockQuery
())
->
setViewer
(
$user
)
->
withIDs
(
array
(
$this
->
id
))
->
executeOne
();
if
(!
$mock
)
{
return
new
Aphront404Response
();
}
$mock_uri
=
'/M'
.
$mock
->
getID
();
$comment
=
$request
->
getStr
(
'comment'
);
$content_source
=
PhabricatorContentSource
::
newForSource
(
PhabricatorContentSource
::
SOURCE_WEB
,
array
(
'ip'
=>
$request
->
getRemoteAddr
(),
));
$xactions
=
array
();
$xactions
[]
=
id
(
new
PholioTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_COMMENT
)
->
attachComment
(
id
(
new
PholioTransactionComment
())
->
setContent
(
$comment
));
$editor
=
id
(
new
PholioMockEditor
())
->
setActor
(
$user
)
->
setContentSource
(
$content_source
)
->
setContinueOnException
(
$request
->
isContinueRequest
());
try
{
$xactions
=
$editor
->
applyTransactions
(
$mock
,
$xactions
);
}
catch
(
PhabricatorApplicationTransactionNoEffectException
$ex
)
{
return
id
(
new
PhabricatorApplicationTransactionNoEffectResponse
())
->
setCancelURI
(
$mock_uri
)
->
setException
(
$ex
);
}
if
(
$request
->
isAjax
())
{
return
id
(
new
PhabricatorApplicationTransactionResponse
())
->
setViewer
(
$user
)
->
setTransactions
(
$xactions
)
->
setAnchorOffset
(
$request
->
getStr
(
'anchor'
));
}
else
{
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$mock_uri
);
}
}
}
Event Timeline
Log In to Comment