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: This probably needs to move somewhere more central as we move | // TODO: Subclass ApplicationTransactionCommentQuery to do this for real. | ||||
| // away from DifferentialInlineCommentQuery, but | |||||
| // PhabricatorApplicationTransactionCommentQuery is currently `final` and | |||||
| // I'm not yet decided on how to approach that. For now, just get the PHIDs | |||||
| // and then execute a PHID-based query through the standard stack. | |||||
| $table = new DifferentialTransactionComment(); | $table = new DifferentialTransactionComment(); | ||||
| $conn_r = $table->establishConnection('r'); | $conn_r = $table->establishConnection('r'); | ||||
| $phids = queryfx_all( | $phids = queryfx_all( | ||||
| $conn_r, | $conn_r, | ||||
| 'SELECT phid FROM %T | 'SELECT phid FROM %T | ||||
| WHERE revisionPHID = %s | WHERE revisionPHID = %s | ||||
| AND authorPHID = %s | AND authorPHID = %s | ||||
| AND transactionPHID IS NULL | AND transactionPHID IS NULL | ||||
| AND isDeleted = 0', | AND isDeleted = 0', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| $revision->getPHID(), | $revision->getPHID(), | ||||
| $viewer->getPHID()); | $viewer->getPHID()); | ||||
| $phids = ipull($phids, 'phid'); | $phids = ipull($phids, 'phid'); | ||||
| if (!$phids) { | if (!$phids) { | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| $comments = id(new PhabricatorApplicationTransactionCommentQuery()) | $comments = id(new PhabricatorApplicationTransactionTemplatedCommentQuery()) | ||||
| ->setTemplate(new DifferentialTransactionComment()) | ->setTemplate(new DifferentialTransactionComment()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs($phids) | ->withPHIDs($phids) | ||||
| ->execute(); | ->execute(); | ||||
| $comments = PhabricatorInlineCommentController::loadAndAttachReplies( | $comments = PhabricatorInlineCommentController::loadAndAttachReplies( | ||||
| $viewer, | $viewer, | ||||
| $comments); | $comments); | ||||
| return $comments; | return $comments; | ||||
| } | } | ||||
| } | } | ||||