1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 07:11:04 +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:
epriestley 2013-07-26 13:00:01 -07:00
parent 3071797d03
commit 7522b45ef2
3 changed files with 19 additions and 45 deletions

View file

@ -23,7 +23,10 @@ final class PonderVoteSaveController extends PonderController {
if ($this->kind == "question") {
$target = PonderQuestionQuery::loadSingleByPHID($user, $phid);
} else if ($this->kind == "answer") {
$target = PonderAnswerQuery::loadSingleByPHID($user, $phid);
$target = id(new PonderAnswerQuery())
->setViewer($user)
->withPHID($phid)
->executeOne();
}
if (!$target) {

View file

@ -7,6 +7,21 @@ final class PonderAnswerQuery extends PhabricatorOffsetPagedQuery {
private $authorPHID;
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) {
$this->id = $qid;
return $this;
@ -27,38 +42,6 @@ final class PonderAnswerQuery extends PhabricatorOffsetPagedQuery {
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) {
$where = array();
if ($this->id) {

View file

@ -53,14 +53,6 @@ final class PonderAnswer extends PonderDAO
) + parent::getConfiguration();
}
public function setTitle($title) {
$this->title = $title;
if (!$this->getID()) {
$this->originalTitle = $title;
}
return $this;
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_ANSW);
@ -75,10 +67,6 @@ final class PonderAnswer extends PonderDAO
return PhabricatorContentSource::newFromSerialized($this->contentSource);
}
public function getAnswers() {
return $this->loadRelatives(new PonderAnswer(), "questionID");
}
public function getMarkupField() {
return self::MARKUP_FIELD_CONTENT;
}