2015-12-21 16:08:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorTransactionsFulltextEngineExtension
|
|
|
|
extends PhabricatorFulltextEngineExtension {
|
|
|
|
|
|
|
|
const EXTENSIONKEY = 'transactions';
|
|
|
|
|
|
|
|
public function getExtensionName() {
|
|
|
|
return pht('Comments');
|
|
|
|
}
|
|
|
|
|
2017-09-01 18:19:01 +02:00
|
|
|
public function shouldEnrichFulltextObject($object) {
|
2015-12-21 16:08:17 +01:00
|
|
|
return ($object instanceof PhabricatorApplicationTransactionInterface);
|
|
|
|
}
|
|
|
|
|
2017-09-01 18:19:01 +02:00
|
|
|
public function enrichFulltextObject(
|
2015-12-21 16:08:17 +01:00
|
|
|
$object,
|
|
|
|
PhabricatorSearchAbstractDocument $document) {
|
|
|
|
|
|
|
|
$query = PhabricatorApplicationTransactionQuery::newQueryForObject($object);
|
|
|
|
if (!$query) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$xactions = $query
|
|
|
|
->setViewer($this->getViewer())
|
|
|
|
->withObjectPHIDs(array($object->getPHID()))
|
2017-09-28 21:48:19 +02:00
|
|
|
->withComments(true)
|
2015-12-21 16:08:17 +01:00
|
|
|
->needComments(true)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
foreach ($xactions as $xaction) {
|
|
|
|
if (!$xaction->hasComment()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$comment = $xaction->getComment();
|
|
|
|
|
|
|
|
$document->addField(
|
|
|
|
PhabricatorSearchDocumentFieldType::FIELD_COMMENT,
|
|
|
|
$comment->getContent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|