Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93118585
PonderSearchIndexer.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
Tue, Nov 26, 08:31
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Nov 28, 08:31 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22572248
Attached To
rPH Phabricator
PonderSearchIndexer.php
View Options
<?php
final
class
PonderSearchIndexer
extends
PhabricatorSearchDocumentIndexer
{
public
function
getIndexableObject
()
{
return
new
PonderQuestion
();
}
protected
function
buildAbstractDocumentByPHID
(
$phid
)
{
$question
=
$this
->
loadDocumentByPHID
(
$phid
);
$question
->
attachRelated
();
$doc
=
new
PhabricatorSearchAbstractDocument
();
$doc
->
setPHID
(
$question
->
getPHID
());
$doc
->
setDocumentType
(
PonderPHIDTypeQuestion
::
TYPECONST
);
$doc
->
setDocumentTitle
(
$question
->
getTitle
());
$doc
->
setDocumentCreated
(
$question
->
getDateCreated
());
$doc
->
setDocumentModified
(
$question
->
getDateModified
());
$doc
->
addField
(
PhabricatorSearchField
::
FIELD_BODY
,
$question
->
getContent
());
$doc
->
addRelationship
(
PhabricatorSearchRelationship
::
RELATIONSHIP_AUTHOR
,
$question
->
getAuthorPHID
(),
PhabricatorPHIDConstants
::
PHID_TYPE_USER
,
$question
->
getDateCreated
());
$comments
=
$question
->
getComments
();
foreach
(
$comments
as
$curcomment
)
{
$doc
->
addField
(
PhabricatorSearchField
::
FIELD_COMMENT
,
$curcomment
->
getContent
());
}
$answers
=
$question
->
getAnswers
();
foreach
(
$answers
as
$curanswer
)
{
if
(
strlen
(
$curanswer
->
getContent
()))
{
$doc
->
addField
(
PhabricatorSearchField
::
FIELD_COMMENT
,
$curanswer
->
getContent
());
}
$answer_comments
=
$curanswer
->
getComments
();
foreach
(
$answer_comments
as
$curcomment
)
{
$doc
->
addField
(
PhabricatorSearchField
::
FIELD_COMMENT
,
$curcomment
->
getContent
());
}
}
$subscribers
=
PhabricatorSubscribersQuery
::
loadSubscribersForPHID
(
$question
->
getPHID
());
$handles
=
id
(
new
PhabricatorObjectHandleData
(
$subscribers
))
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
())
->
loadHandles
();
foreach
(
$handles
as
$phid
=>
$handle
)
{
$doc
->
addRelationship
(
PhabricatorSearchRelationship
::
RELATIONSHIP_SUBSCRIBER
,
$phid
,
$handle
->
getType
(),
$question
->
getDateModified
());
// Bogus timestamp.
}
return
$doc
;
}
}
Event Timeline
Log In to Comment