mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 15:21:03 +01:00
Clean up some PonderAnswer / PonderAnswerQuery cruft
Summary: Ref T3578. Ref T2715. Clean up some cruft so we can use Application PHIDs for "ANSW" and eventually unbeta Ponder. Test Plan: Grep, voted on an answer. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715, T3578 Differential Revision: https://secure.phabricator.com/D6580
This commit is contained in:
parent
3071797d03
commit
7522b45ef2
3 changed files with 19 additions and 45 deletions
|
@ -23,7 +23,10 @@ final class PonderVoteSaveController extends PonderController {
|
||||||
if ($this->kind == "question") {
|
if ($this->kind == "question") {
|
||||||
$target = PonderQuestionQuery::loadSingleByPHID($user, $phid);
|
$target = PonderQuestionQuery::loadSingleByPHID($user, $phid);
|
||||||
} else if ($this->kind == "answer") {
|
} else if ($this->kind == "answer") {
|
||||||
$target = PonderAnswerQuery::loadSingleByPHID($user, $phid);
|
$target = id(new PonderAnswerQuery())
|
||||||
|
->setViewer($user)
|
||||||
|
->withPHID($phid)
|
||||||
|
->executeOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
|
|
@ -7,6 +7,21 @@ final class PonderAnswerQuery extends PhabricatorOffsetPagedQuery {
|
||||||
private $authorPHID;
|
private $authorPHID;
|
||||||
private $orderNewest;
|
private $orderNewest;
|
||||||
|
|
||||||
|
private $viewer;
|
||||||
|
|
||||||
|
public function setViewer(PhabricatorUser $viewer) {
|
||||||
|
$this->viewer = $viewer;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getViewer() {
|
||||||
|
return $this->viewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function executeOne() {
|
||||||
|
return head($this->execute());
|
||||||
|
}
|
||||||
|
|
||||||
public function withID($qid) {
|
public function withID($qid) {
|
||||||
$this->id = $qid;
|
$this->id = $qid;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -27,38 +42,6 @@ final class PonderAnswerQuery extends PhabricatorOffsetPagedQuery {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function loadByAuthor($viewer, $author_phid, $offset, $count) {
|
|
||||||
if (!$viewer) {
|
|
||||||
throw new Exception("Must set viewer when calling loadByAuthor");
|
|
||||||
}
|
|
||||||
|
|
||||||
return id(new PonderAnswerQuery())
|
|
||||||
->withAuthorPHID($author_phid)
|
|
||||||
->setOffset($offset)
|
|
||||||
->setLimit($count)
|
|
||||||
->orderByNewest(true)
|
|
||||||
->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function loadSingle($viewer, $id) {
|
|
||||||
if (!$viewer) {
|
|
||||||
throw new Exception("Must set viewer when calling loadSingle");
|
|
||||||
}
|
|
||||||
return idx(id(new PonderAnswerQuery())
|
|
||||||
->withID($id)
|
|
||||||
->execute(), $id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function loadSingleByPHID($viewer, $phid) {
|
|
||||||
if (!$viewer) {
|
|
||||||
throw new Exception("Must set viewer when calling loadSingle");
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_shift(id(new PonderAnswerQuery())
|
|
||||||
->withPHID($phid)
|
|
||||||
->execute());
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildWhereClause($conn_r) {
|
private function buildWhereClause($conn_r) {
|
||||||
$where = array();
|
$where = array();
|
||||||
if ($this->id) {
|
if ($this->id) {
|
||||||
|
|
|
@ -53,14 +53,6 @@ final class PonderAnswer extends PonderDAO
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTitle($title) {
|
|
||||||
$this->title = $title;
|
|
||||||
if (!$this->getID()) {
|
|
||||||
$this->originalTitle = $title;
|
|
||||||
}
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generatePHID() {
|
public function generatePHID() {
|
||||||
return PhabricatorPHID::generateNewPHID(
|
return PhabricatorPHID::generateNewPHID(
|
||||||
PhabricatorPHIDConstants::PHID_TYPE_ANSW);
|
PhabricatorPHIDConstants::PHID_TYPE_ANSW);
|
||||||
|
@ -75,10 +67,6 @@ final class PonderAnswer extends PonderDAO
|
||||||
return PhabricatorContentSource::newFromSerialized($this->contentSource);
|
return PhabricatorContentSource::newFromSerialized($this->contentSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAnswers() {
|
|
||||||
return $this->loadRelatives(new PonderAnswer(), "questionID");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMarkupField() {
|
public function getMarkupField() {
|
||||||
return self::MARKUP_FIELD_CONTENT;
|
return self::MARKUP_FIELD_CONTENT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue