Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104746529
PonderQuestionEditor.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
Wed, Mar 12, 01:12
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Mar 14, 01:12 (2 d)
Engine
blob
Format
Raw Data
Handle
24829507
Attached To
rPH Phabricator
PonderQuestionEditor.php
View Options
<?php
final
class
PonderQuestionEditor
extends
PhabricatorEditor
{
private
$question
;
private
$shouldEmail
=
true
;
public
function
setQuestion
(
PonderQuestion
$question
)
{
$this
->
question
=
$question
;
return
$this
;
}
public
function
setShouldEmail
(
$se
)
{
$this
->
shouldEmail
=
$se
;
return
$this
;
}
public
function
save
()
{
$actor
=
$this
->
requireActor
();
if
(!
$this
->
question
)
{
throw
new
Exception
(
"Must set question before saving it"
);
}
$question
=
$this
->
question
;
$question
->
save
();
$question
->
attachRelated
();
id
(
new
PhabricatorSearchIndexer
())
->
indexDocumentByPHID
(
$question
->
getPHID
());
// subscribe author and @mentions
$subeditor
=
id
(
new
PhabricatorSubscriptionsEditor
())
->
setObject
(
$question
)
->
setActor
(
$actor
);
$subeditor
->
subscribeExplicit
(
array
(
$question
->
getAuthorPHID
()));
$content
=
$question
->
getContent
();
$at_mention_phids
=
PhabricatorMarkupEngine
::
extractPHIDsFromMentions
(
array
(
$content
)
);
$subeditor
->
subscribeImplicit
(
$at_mention_phids
);
$subeditor
->
save
();
if
(
$this
->
shouldEmail
&&
$at_mention_phids
)
{
id
(
new
PonderMentionMail
(
$question
,
$question
,
$actor
))
->
setToPHIDs
(
$at_mention_phids
)
->
send
();
}
}
}
Event Timeline
Log In to Comment