Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2307527
PonderSearchIndexer.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
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
(
PhabricatorPHIDConstants
::
PHID_TYPE_QUES
);
$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
))
->
loadHandles
();
foreach
(
$handles
as
$phid
=>
$handle
)
{
$doc
->
addRelationship
(
PhabricatorSearchRelationship
::
RELATIONSHIP_SUBSCRIBER
,
$phid
,
$handle
->
getType
(),
$question
->
getDateModified
());
// Bogus timestamp.
}
return
$doc
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Sep 16, 2:36 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
441568
Default Alt Text
PonderSearchIndexer.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment