1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Modernize Ponder edge types

Summary: Modernize Ponder edges to subclass `PhabricatorEdgeType`. Largely based on D11045.

Test Plan: I couldn't actually figure out how to get these strings to show up anywhere.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Krenair, chad, epriestley

Differential Revision: https://secure.phabricator.com/D11083
This commit is contained in:
Joshua Spence 2015-01-01 11:20:22 +11:00
parent 83d1e3edb5
commit 8e3396ce21
11 changed files with 445 additions and 57 deletions

View file

@ -2840,6 +2840,7 @@ phutil_register_library_map(array(
'PonderAnswerCommentController' => 'applications/ponder/controller/PonderAnswerCommentController.php',
'PonderAnswerEditController' => 'applications/ponder/controller/PonderAnswerEditController.php',
'PonderAnswerEditor' => 'applications/ponder/editor/PonderAnswerEditor.php',
'PonderAnswerHasVotingUserEdgeType' => 'applications/ponder/edge/PonderAnswerHasVotingUserEdgeType.php',
'PonderAnswerHistoryController' => 'applications/ponder/controller/PonderAnswerHistoryController.php',
'PonderAnswerPHIDType' => 'applications/ponder/phid/PonderAnswerPHIDType.php',
'PonderAnswerQuery' => 'applications/ponder/query/PonderAnswerQuery.php',
@ -2855,6 +2856,7 @@ phutil_register_library_map(array(
'PonderQuestionCommentController' => 'applications/ponder/controller/PonderQuestionCommentController.php',
'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php',
'PonderQuestionEditor' => 'applications/ponder/editor/PonderQuestionEditor.php',
'PonderQuestionHasVotingUserEdgeType' => 'applications/ponder/edge/PonderQuestionHasVotingUserEdgeType.php',
'PonderQuestionHistoryController' => 'applications/ponder/controller/PonderQuestionHistoryController.php',
'PonderQuestionListController' => 'applications/ponder/controller/PonderQuestionListController.php',
'PonderQuestionMailReceiver' => 'applications/ponder/mail/PonderQuestionMailReceiver.php',
@ -2877,6 +2879,8 @@ phutil_register_library_map(array(
'PonderVote' => 'applications/ponder/constants/PonderVote.php',
'PonderVoteEditor' => 'applications/ponder/editor/PonderVoteEditor.php',
'PonderVoteSaveController' => 'applications/ponder/controller/PonderVoteSaveController.php',
'PonderVotingUserHasAnswerEdgeType' => 'applications/ponder/edge/PonderVotingUserHasAnswerEdgeType.php',
'PonderVotingUserHasQuestionEdgeType' => 'applications/ponder/edge/PonderVotingUserHasQuestionEdgeType.php',
'ProjectBoardTaskCard' => 'applications/project/view/ProjectBoardTaskCard.php',
'ProjectCanLockProjectsCapability' => 'applications/project/capability/ProjectCanLockProjectsCapability.php',
'ProjectConduitAPIMethod' => 'applications/project/conduit/ProjectConduitAPIMethod.php',
@ -6143,6 +6147,7 @@ phutil_register_library_map(array(
'PonderAnswerCommentController' => 'PonderController',
'PonderAnswerEditController' => 'PonderController',
'PonderAnswerEditor' => 'PonderEditor',
'PonderAnswerHasVotingUserEdgeType' => 'PhabricatorEdgeType',
'PonderAnswerHistoryController' => 'PonderController',
'PonderAnswerPHIDType' => 'PhabricatorPHIDType',
'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
@ -6168,6 +6173,7 @@ phutil_register_library_map(array(
'PonderQuestionCommentController' => 'PonderController',
'PonderQuestionEditController' => 'PonderController',
'PonderQuestionEditor' => 'PonderEditor',
'PonderQuestionHasVotingUserEdgeType' => 'PhabricatorEdgeType',
'PonderQuestionHistoryController' => 'PonderController',
'PonderQuestionListController' => 'PonderController',
'PonderQuestionMailReceiver' => 'PhabricatorObjectMailReceiver',
@ -6189,6 +6195,8 @@ phutil_register_library_map(array(
'PonderVote' => 'PonderConstants',
'PonderVoteEditor' => 'PhabricatorEditor',
'PonderVoteSaveController' => 'PonderController',
'PonderVotingUserHasAnswerEdgeType' => 'PhabricatorEdgeType',
'PonderVotingUserHasQuestionEdgeType' => 'PhabricatorEdgeType',
'ProjectCanLockProjectsCapability' => 'PhabricatorPolicyCapability',
'ProjectConduitAPIMethod' => 'ConduitAPIMethod',
'ProjectCreateConduitAPIMethod' => 'ProjectConduitAPIMethod',

View file

@ -0,0 +1,105 @@
<?php
final class PonderAnswerHasVotingUserEdgeType extends PhabricatorEdgeType {
const EDGECONST = 19;
public function shouldWriteInverseTransactions() {
return true;
}
public function getInverseEdgeConstant() {
return PonderVotingUserHasAnswerEdgeType::EDGECONST;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s voting user(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s voting user(s): %s.',
$actor,
$rem_count,
$rem_edges);
}
public function getTransactionEditString(
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited %s voting user(s), added %s: %s; removed %s: %s.',
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
public function getFeedAddString(
$actor,
$object,
$add_count,
$add_edges) {
return pht(
'%s added %s voting user(s) to %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s voting user(s) from %s: %s.',
$actor,
$rem_count,
$object,
$rem_edges);
}
public function getFeedEditString(
$actor,
$object,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited %s voting user(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$total_count,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -0,0 +1,105 @@
<?php
final class PonderQuestionHasVotingUserEdgeType extends PhabricatorEdgeType {
const EDGECONST = 17;
public function shouldWriteInverseTransactions() {
return true;
}
public function getInverseEdgeConstant() {
return PonderVotingUserHasQuestionEdgeType::EDGECONST;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s voting user(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s voting user(s): %s.',
$actor,
$rem_count,
$rem_edges);
}
public function getTransactionEditString(
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited %s voting user(s), added %s: %s; removed %s: %s.',
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
public function getFeedAddString(
$actor,
$object,
$add_count,
$add_edges) {
return pht(
'%s added %s voting user(s) to %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s voting user(s) from %s: %s.',
$actor,
$rem_count,
$object,
$rem_edges);
}
public function getFeedEditString(
$actor,
$object,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited %s voting user(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$total_count,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -0,0 +1,105 @@
<?php
final class PonderVotingUserHasAnswerEdgeType extends PhabricatorEdgeType {
const EDGECONST = 20;
public function shouldWriteInverseTransactions() {
return true;
}
public function getInverseEdgeConstant() {
return PonderAnswerHasVotingUserEdgeType::EDGECONST;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s answer(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s answer(s): %s.',
$actor,
$rem_count,
$rem_edges);
}
public function getTransactionEditString(
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited %s answer(s), added %s: %s; removed %s: %s.',
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
public function getFeedAddString(
$actor,
$object,
$add_count,
$add_edges) {
return pht(
'%s added %s answer(s) to %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s answer(s) from %s: %s.',
$actor,
$rem_count,
$object,
$rem_edges);
}
public function getFeedEditString(
$actor,
$object,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited %s answer(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$total_count,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -0,0 +1,105 @@
<?php
final class PonderVotingUserHasQuestionEdgeType extends PhabricatorEdgeType {
const EDGECONST = 18;
public function shouldWriteInverseTransactions() {
return true;
}
public function getInverseEdgeConstant() {
return PonderQuestionHasVotingUserEdgeType::EDGECONST;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s question(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s question(s): %s.',
$actor,
$rem_count,
$rem_edges);
}
public function getTransactionEditString(
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited %s question(s), added %s: %s; removed %s: %s.',
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
public function getFeedAddString(
$actor,
$object,
$add_count,
$add_edges) {
return pht(
'%s added %s question(s) to %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s question(s) from %s: %s.',
$actor,
$rem_count,
$object,
$rem_edges);
}
public function getFeedEditString(
$actor,
$object,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited %s question(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$total_count,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -98,7 +98,7 @@ final class PonderAnswerQuery
if ($this->needViewerVotes) {
$viewer_phid = $this->getViewer()->getPHID();
$etype = PhabricatorEdgeConfig::TYPE_ANSWER_HAS_VOTING_USER;
$etype = PonderAnswerHasVotingUserEdgeType::EDGECONST;
$edges = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(mpull($answers, 'getPHID'))
->withDestinationPHIDs(array($viewer_phid))

View file

@ -159,7 +159,7 @@ final class PonderQuestionQuery
if ($this->needViewerVotes) {
$viewer_phid = $this->getViewer()->getPHID();
$etype = PhabricatorEdgeConfig::TYPE_QUESTION_HAS_VOTING_USER;
$etype = PonderQuestionHasVotingUserEdgeType::EDGECONST;
$edges = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(mpull($questions, 'getPHID'))
->withDestinationPHIDs(array($viewer_phid))

View file

@ -166,7 +166,7 @@ final class PonderAnswer extends PonderDAO
// votable interface
public function getUserVoteEdgeType() {
return PhabricatorEdgeConfig::TYPE_VOTING_USER_HAS_ANSWER;
return PonderVotingUserHasAnswerEdgeType::EDGECONST;
}
public function getVotablePHID() {

View file

@ -87,16 +87,16 @@ final class PonderQuestion extends PonderDAO
->withDestinationPHIDs($qa_phids)
->withEdgeTypes(
array(
PhabricatorEdgeConfig::TYPE_VOTING_USER_HAS_QUESTION,
PhabricatorEdgeConfig::TYPE_VOTING_USER_HAS_ANSWER,
PonderVotingUserHasQuestionEdgeType::EDGECONST,
PonderVotingUserHasAnswerEdgeType::EDGECONST,
))
->needEdgeData(true)
->execute();
$question_edge =
$edges[$user_phid][PhabricatorEdgeConfig::TYPE_VOTING_USER_HAS_QUESTION];
$edges[$user_phid][PonderVotingUserHasQuestionEdgeType::EDGECONST];
$answer_edges =
$edges[$user_phid][PhabricatorEdgeConfig::TYPE_VOTING_USER_HAS_ANSWER];
$edges[$user_phid][PonderVotingUserHasAnswerEdgeType::EDGECONST];
$edges = null;
$this->setUserVote(idx($question_edge, $this->getPHID()));
@ -198,7 +198,7 @@ final class PonderQuestion extends PonderDAO
// votable interface
public function getUserVoteEdgeType() {
return PhabricatorEdgeConfig::TYPE_VOTING_USER_HAS_QUESTION;
return PonderVotingUserHasQuestionEdgeType::EDGECONST;
}
public function getVotablePHID() {

View file

@ -11,11 +11,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
const TYPE_PROJ_MEMBER = 13;
const TYPE_MEMBER_OF_PROJ = 14;
const TYPE_QUESTION_HAS_VOTING_USER = 17;
const TYPE_VOTING_USER_HAS_QUESTION = 18;
const TYPE_ANSWER_HAS_VOTING_USER = 19;
const TYPE_VOTING_USER_HAS_ANSWER = 20;
const TYPE_OBJECT_HAS_SUBSCRIBER = 21;
const TYPE_SUBSCRIBED_TO_OBJECT = 22;
@ -123,13 +118,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
self::TYPE_PROJ_MEMBER => self::TYPE_MEMBER_OF_PROJ,
self::TYPE_MEMBER_OF_PROJ => self::TYPE_PROJ_MEMBER,
self::TYPE_QUESTION_HAS_VOTING_USER =>
self::TYPE_VOTING_USER_HAS_QUESTION,
self::TYPE_VOTING_USER_HAS_QUESTION =>
self::TYPE_QUESTION_HAS_VOTING_USER,
self::TYPE_ANSWER_HAS_VOTING_USER => self::TYPE_VOTING_USER_HAS_ANSWER,
self::TYPE_VOTING_USER_HAS_ANSWER => self::TYPE_ANSWER_HAS_VOTING_USER,
self::TYPE_OBJECT_HAS_SUBSCRIBER => self::TYPE_SUBSCRIBED_TO_OBJECT,
self::TYPE_SUBSCRIBED_TO_OBJECT => self::TYPE_OBJECT_HAS_SUBSCRIBER,
@ -221,13 +209,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
return '%s edited member(s), added %d: %s; removed %d: %s.';
case self::TYPE_MEMBER_OF_PROJ:
return '%s edited project(s), added %d: %s; removed %d: %s.';
case self::TYPE_QUESTION_HAS_VOTING_USER:
case self::TYPE_ANSWER_HAS_VOTING_USER:
return '%s edited voting user(s), added %d: %s; removed %d: %s.';
case self::TYPE_VOTING_USER_HAS_QUESTION:
return '%s edited question(s), added %d: %s; removed %d: %s.';
case self::TYPE_VOTING_USER_HAS_ANSWER:
return '%s edited answer(s), added %d: %s; removed %d: %s.';
case self::TYPE_OBJECT_HAS_SUBSCRIBER:
return '%s edited subscriber(s), added %d: %s; removed %d: %s.';
case self::TYPE_SUBSCRIBED_TO_OBJECT:
@ -275,13 +256,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
return '%s added %d member(s): %s.';
case self::TYPE_MEMBER_OF_PROJ:
return '%s added %d project(s): %s.';
case self::TYPE_QUESTION_HAS_VOTING_USER:
case self::TYPE_ANSWER_HAS_VOTING_USER:
return '%s added %d voting user(s): %s.';
case self::TYPE_VOTING_USER_HAS_QUESTION:
return '%s added %d question(s): %s.';
case self::TYPE_VOTING_USER_HAS_ANSWER:
return '%s added %d answer(s): %s.';
case self::TYPE_OBJECT_HAS_SUBSCRIBER:
return '%s added %d subscriber(s): %s.';
case self::TYPE_OBJECT_HAS_UNSUBSCRIBER:
@ -325,13 +299,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
return '%s removed %d member(s): %s.';
case self::TYPE_MEMBER_OF_PROJ:
return '%s removed %d project(s): %s.';
case self::TYPE_QUESTION_HAS_VOTING_USER:
case self::TYPE_ANSWER_HAS_VOTING_USER:
return '%s removed %d voting user(s): %s.';
case self::TYPE_VOTING_USER_HAS_QUESTION:
return '%s removed %d question(s): %s.';
case self::TYPE_VOTING_USER_HAS_ANSWER:
return '%s removed %d answer(s): %s.';
case self::TYPE_OBJECT_HAS_SUBSCRIBER:
return '%s removed %d subscriber(s): %s.';
case self::TYPE_OBJECT_HAS_UNSUBSCRIBER:
@ -375,13 +342,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
return '%s updated members of %s.';
case self::TYPE_MEMBER_OF_PROJ:
return '%s updated projects of %s.';
case self::TYPE_QUESTION_HAS_VOTING_USER:
case self::TYPE_ANSWER_HAS_VOTING_USER:
return '%s updated voting users of %s.';
case self::TYPE_VOTING_USER_HAS_QUESTION:
return '%s updated questions of %s.';
case self::TYPE_VOTING_USER_HAS_ANSWER:
return '%s updated answers of %s.';
case self::TYPE_OBJECT_HAS_SUBSCRIBER:
return '%s updated subscribers of %s.';
case self::TYPE_OBJECT_HAS_UNSUBSCRIBER:

View file

@ -314,17 +314,17 @@ abstract class PhabricatorBaseEnglishTranslation
),
),
'%s edited voting user(s), added %d: %s; removed %d: %s.' =>
'%s edited voting user(s), added %s: %s; removed %d: %s.' =>
'%s edited voting users, added: %3$s; removed: %5$s',
'%s added %d voting user(s): %s.' => array(
'%s added %s voting user(s): %s.' => array(
array(
'%s added a voting user: %3$s.',
'%s added voting users: %3$s.',
),
),
'%s removed %d voting user(s): %s.' => array(
'%s removed %s voting user(s): %s.' => array(
array(
'%s removed a voting user: %3$s.',
'%s removed voting users: %3$s.',
@ -399,34 +399,34 @@ abstract class PhabricatorBaseEnglishTranslation
'%s edited blocked task(s) for %s, added %s: %s; removed %s: %s.' =>
'%s edited blocked tasks for %s, added: %4$s; removed: %6$s',
'%s edited answer(s), added %d: %s; removed %d: %s.' =>
'%s edited answer(s), added %s: %s; removed %d: %s.' =>
'%s edited answers, added: %3$s; removed: %5$s',
'%s added %d answer(s): %s.' => array(
'%s added %s answer(s): %s.' => array(
array(
'%s added an answer: %3$s.',
'%s added answers: %3$s.',
),
),
'%s removed %d answer(s): %s.' => array(
'%s removed %s answer(s): %s.' => array(
array(
'%s removed a answer: %3$s.',
'%s removed answers: %3$s.',
),
),
'%s edited question(s), added %d: %s; removed %d: %s.' =>
'%s edited question(s), added %s: %s; removed %s: %s.' =>
'%s edited questions, added: %3$s; removed: %5$s',
'%s added %d question(s): %s.' => array(
'%s added %s question(s): %s.' => array(
array(
'%s added a question: %3$s.',
'%s added questions: %3$s.',
),
),
'%s removed %d question(s): %s.' => array(
'%s removed %s question(s): %s.' => array(
array(
'%s removed a question: %3$s.',
'%s removed questions: %3$s.',