Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/query/DifferentialTransactionQuery.php
| <?php | <?php | ||||
| final class DifferentialTransactionQuery | final class DifferentialTransactionQuery | ||||
| extends PhabricatorApplicationTransactionQuery { | extends PhabricatorApplicationTransactionQuery { | ||||
| public function getTemplateApplicationTransaction() { | public function getTemplateApplicationTransaction() { | ||||
| return new DifferentialTransaction(); | return new DifferentialTransaction(); | ||||
| } | } | ||||
| public static function loadUnsubmittedInlineComments( | public static function loadUnsubmittedInlineComments( | ||||
| PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
| DifferentialRevision $revision) { | DifferentialRevision $revision) { | ||||
| // TODO: Subclass ApplicationTransactionCommentQuery to do this for real. | return id(new DifferentialDiffInlineCommentQuery()) | ||||
| $table = new DifferentialTransactionComment(); | |||||
| $conn_r = $table->establishConnection('r'); | |||||
| $phids = queryfx_all( | |||||
| $conn_r, | |||||
| 'SELECT phid FROM %T | |||||
| WHERE revisionPHID = %s | |||||
| AND authorPHID = %s | |||||
| AND transactionPHID IS NULL | |||||
| AND isDeleted = 0', | |||||
| $table->getTableName(), | |||||
| $revision->getPHID(), | |||||
| $viewer->getPHID()); | |||||
| $phids = ipull($phids, 'phid'); | |||||
| if (!$phids) { | |||||
| return array(); | |||||
| } | |||||
| $comments = id(new PhabricatorApplicationTransactionTemplatedCommentQuery()) | |||||
| ->setTemplate(new DifferentialTransactionComment()) | |||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs($phids) | ->withRevisionPHIDs(array($revision->getPHID())) | ||||
| ->withAuthorPHIDs(array($viewer->getPHID())) | |||||
| ->withHasTransaction(false) | |||||
| ->withIsDeleted(false) | |||||
| ->needReplyToComments(true) | |||||
| ->execute(); | ->execute(); | ||||
| $comments = PhabricatorInlineCommentController::loadAndAttachReplies( | |||||
| $viewer, | |||||
| $comments); | |||||
| return $comments; | |||||
| } | } | ||||
| } | } | ||||