mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Modernize Project/Object edges
Summary: Ref T5245. Updates the project/object edge to use a modern class definition. Moves further toward real edges. Test Plan: Added projects to some objects, viewed transactions in transaction record. Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9849
This commit is contained in:
parent
d4b2bfa2f4
commit
33120e377a
16 changed files with 138 additions and 32 deletions
|
@ -2008,9 +2008,11 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectMembersRemoveController' => 'applications/project/controller/PhabricatorProjectMembersRemoveController.php',
|
||||
'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php',
|
||||
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
|
||||
'PhabricatorProjectObjectHasProjectEdgeType' => 'applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php',
|
||||
'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php',
|
||||
'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php',
|
||||
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
|
||||
'PhabricatorProjectProjectHasObjectEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php',
|
||||
'PhabricatorProjectQuery' => 'applications/project/query/PhabricatorProjectQuery.php',
|
||||
'PhabricatorProjectSearchEngine' => 'applications/project/query/PhabricatorProjectSearchEngine.php',
|
||||
'PhabricatorProjectSearchIndexer' => 'applications/project/search/PhabricatorProjectSearchIndexer.php',
|
||||
|
@ -4820,9 +4822,11 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectNameCollisionException' => 'Exception',
|
||||
'PhabricatorProjectObjectHasProjectEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType',
|
||||
'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType',
|
||||
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectProjectHasObjectEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorProjectSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
|
|
|
@ -35,7 +35,7 @@ final class DifferentialProjectsField
|
|||
|
||||
$projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$revision->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
$projects = array_reverse($projects);
|
||||
|
||||
return $projects;
|
||||
|
@ -97,7 +97,9 @@ final class DifferentialProjectsField
|
|||
}
|
||||
|
||||
public function getApplicationTransactionMetadata() {
|
||||
return array('edge:type' => PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
return array(
|
||||
'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
|
||||
);
|
||||
}
|
||||
|
||||
public function parseValueFromCommitMessage($value) {
|
||||
|
|
|
@ -231,7 +231,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
|
||||
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$repository->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
if ($project_phids) {
|
||||
$this->loadHandles($project_phids);
|
||||
$view->addProperty(
|
||||
|
|
|
@ -73,7 +73,7 @@ final class DiffusionRepositoryEditBasicController
|
|||
->setTransactionType($type_edge)
|
||||
->setMetadataValue(
|
||||
'edge:type',
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT)
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)
|
||||
->setNewValue(
|
||||
array(
|
||||
'=' => array_fuse($v_projects),
|
||||
|
|
|
@ -265,7 +265,7 @@ final class DiffusionRepositoryEditMainController
|
|||
|
||||
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$repository->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
if ($project_phids) {
|
||||
$this->loadHandles($project_phids);
|
||||
$project_text = $this->renderHandlesForPHIDs($project_phids);
|
||||
|
|
|
@ -103,7 +103,7 @@ final class HeraldPholioMockAdapter extends HeraldAdapter {
|
|||
case self::FIELD_PROJECTS:
|
||||
return PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$this->getMock()->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
}
|
||||
|
||||
return parent::getHeraldField($field);
|
||||
|
|
|
@ -76,7 +76,7 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
|||
} else {
|
||||
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$paste->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
$v_projects = array_reverse($v_projects);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
|||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
||||
->setNewValue($v_policy);
|
||||
|
||||
$proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
|
||||
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
$xactions[] = id(new PhabricatorPasteTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $proj_edge_type)
|
||||
|
|
|
@ -49,7 +49,7 @@ final class PholioMockEditController extends PholioController {
|
|||
} else {
|
||||
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$mock->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
$v_projects = array_reverse($v_projects);
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ final class PholioMockEditController extends PholioController {
|
|||
}
|
||||
|
||||
if (!$errors) {
|
||||
$proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
|
||||
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
$xactions[] = id(new PholioTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $proj_edge_type)
|
||||
|
|
|
@ -27,7 +27,7 @@ final class PonderQuestionEditController extends PonderController {
|
|||
}
|
||||
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$question->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
$v_projects = array_reverse($v_projects);
|
||||
} else {
|
||||
$question = id(new PonderQuestion())
|
||||
|
@ -70,7 +70,7 @@ final class PonderQuestionEditController extends PonderController {
|
|||
->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT)
|
||||
->setNewValue($v_content);
|
||||
|
||||
$proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
|
||||
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
$xactions[] = id(new PonderQuestionTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $proj_edge_type)
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectObjectHasProjectEdgeType
|
||||
extends PhabricatorEdgeType {
|
||||
|
||||
const EDGECONST = 41;
|
||||
|
||||
public function getInverseEdgeConstant() {
|
||||
return PhabricatorProjectProjectHasObjectEdgeType::EDGECONST;
|
||||
}
|
||||
|
||||
public function getTransactionAddString(
|
||||
$actor,
|
||||
$add_count,
|
||||
$add_edges) {
|
||||
|
||||
return pht(
|
||||
'%s added %s project(s): %s.',
|
||||
$actor,
|
||||
$add_count,
|
||||
$add_edges);
|
||||
}
|
||||
|
||||
public function getTransactionRemoveString(
|
||||
$actor,
|
||||
$rem_count,
|
||||
$rem_edges) {
|
||||
|
||||
return pht(
|
||||
'%s removed %s project(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 project(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 project(s) to %s: %s.',
|
||||
$actor,
|
||||
$add_count,
|
||||
$object,
|
||||
$add_edges);
|
||||
}
|
||||
|
||||
public function getFeedRemoveString(
|
||||
$actor,
|
||||
$object,
|
||||
$rem_count,
|
||||
$rem_edges) {
|
||||
|
||||
return pht(
|
||||
'%s removed %s project(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 project(s) for %s, added %s: %s; removed %s: %s.',
|
||||
$actor,
|
||||
$total_count,
|
||||
$object,
|
||||
$add_count,
|
||||
$add_edges,
|
||||
$rem_count,
|
||||
$rem_edges);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectProjectHasObjectEdgeType
|
||||
extends PhabricatorEdgeType {
|
||||
|
||||
const EDGECONST = 42;
|
||||
|
||||
public function getInverseEdgeConstant() {
|
||||
return PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
}
|
||||
|
||||
}
|
|
@ -31,7 +31,7 @@ final class PhabricatorProjectUIEventListener
|
|||
|
||||
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$object->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
if ($project_phids) {
|
||||
$project_phids = array_reverse($project_phids);
|
||||
$handles = id(new PhabricatorHandleQuery())
|
||||
|
|
|
@ -208,7 +208,7 @@ final class PhabricatorRepositoryQuery
|
|||
|
||||
public function didFilterPage(array $repositories) {
|
||||
if ($this->needProjectPHIDs) {
|
||||
$type_project = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
|
||||
$type_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
|
||||
$edge_query = id(new PhabricatorEdgeQuery())
|
||||
->withSourcePHIDs(mpull($repositories, 'getPHID'))
|
||||
|
|
|
@ -38,7 +38,7 @@ final class PhabricatorSlowvoteEditController
|
|||
} else {
|
||||
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$poll->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
$v_projects = array_reverse($v_projects);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ final class PhabricatorSlowvoteEditController
|
|||
->setNewValue($v_view_policy);
|
||||
|
||||
if (empty($errors)) {
|
||||
$proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
|
||||
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
$xactions[] = id(new PhabricatorSlowvoteTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $proj_edge_type)
|
||||
|
|
|
@ -1153,7 +1153,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
}
|
||||
|
||||
if ($phids) {
|
||||
$edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
|
||||
$edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
$block_xactions[] = newv(get_class(head($xactions)), array())
|
||||
->setIgnoreOnNoEffect(true)
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
|
@ -1967,7 +1967,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
if ($object instanceof PhabricatorProjectInterface) {
|
||||
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$object->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
} else {
|
||||
$project_phids = $object->getProjectPHIDs();
|
||||
}
|
||||
|
|
|
@ -57,9 +57,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
const TYPE_OBJECT_USES_CREDENTIAL = 39;
|
||||
const TYPE_CREDENTIAL_USED_BY_OBJECT = 40;
|
||||
|
||||
const TYPE_OBJECT_HAS_PROJECT = 41;
|
||||
const TYPE_PROJECT_HAS_OBJECT = 42;
|
||||
|
||||
const TYPE_OBJECT_HAS_COLUMN = 43;
|
||||
const TYPE_COLUMN_HAS_OBJECT = 44;
|
||||
|
||||
|
@ -193,9 +190,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
self::TYPE_OBJECT_USES_CREDENTIAL => self::TYPE_CREDENTIAL_USED_BY_OBJECT,
|
||||
self::TYPE_CREDENTIAL_USED_BY_OBJECT => self::TYPE_OBJECT_USES_CREDENTIAL,
|
||||
|
||||
self::TYPE_OBJECT_HAS_PROJECT => self::TYPE_PROJECT_HAS_OBJECT,
|
||||
self::TYPE_PROJECT_HAS_OBJECT => self::TYPE_OBJECT_HAS_PROJECT,
|
||||
|
||||
self::TYPE_OBJECT_HAS_COLUMN => self::TYPE_COLUMN_HAS_OBJECT,
|
||||
self::TYPE_COLUMN_HAS_OBJECT => self::TYPE_OBJECT_HAS_COLUMN,
|
||||
|
||||
|
@ -276,7 +270,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
return '%s edited member(s), added %d: %s; removed %d: %s.';
|
||||
case self::TYPE_MEMBER_OF_PROJ:
|
||||
case self::TYPE_COMMIT_HAS_PROJECT:
|
||||
case self::TYPE_OBJECT_HAS_PROJECT:
|
||||
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:
|
||||
|
@ -291,7 +284,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
case self::TYPE_UNSUBSCRIBED_FROM_OBJECT:
|
||||
case self::TYPE_FILE_HAS_OBJECT:
|
||||
case self::TYPE_CONTRIBUTED_TO_OBJECT:
|
||||
case self::TYPE_PROJECT_HAS_OBJECT:
|
||||
return '%s edited object(s), added %d: %s; removed %d: %s.';
|
||||
case self::TYPE_OBJECT_HAS_UNSUBSCRIBER:
|
||||
return '%s edited unsubcriber(s), added %d: %s; removed %d: %s.';
|
||||
|
@ -353,7 +345,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
return '%s added %d member(s): %s.';
|
||||
case self::TYPE_MEMBER_OF_PROJ:
|
||||
case self::TYPE_COMMIT_HAS_PROJECT:
|
||||
case self::TYPE_OBJECT_HAS_PROJECT:
|
||||
return '%s added %d project(s): %s.';
|
||||
case self::TYPE_QUESTION_HAS_VOTING_USER:
|
||||
case self::TYPE_ANSWER_HAS_VOTING_USER:
|
||||
|
@ -394,7 +385,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
case self::TYPE_UNSUBSCRIBED_FROM_OBJECT:
|
||||
case self::TYPE_FILE_HAS_OBJECT:
|
||||
case self::TYPE_CONTRIBUTED_TO_OBJECT:
|
||||
case self::TYPE_PROJECT_HAS_OBJECT:
|
||||
default:
|
||||
return '%s added %d object(s): %s.';
|
||||
|
||||
|
@ -428,7 +418,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
return '%s removed %d member(s): %s.';
|
||||
case self::TYPE_MEMBER_OF_PROJ:
|
||||
case self::TYPE_COMMIT_HAS_PROJECT:
|
||||
case self::TYPE_OBJECT_HAS_PROJECT:
|
||||
return '%s removed %d project(s): %s.';
|
||||
case self::TYPE_QUESTION_HAS_VOTING_USER:
|
||||
case self::TYPE_ANSWER_HAS_VOTING_USER:
|
||||
|
@ -467,7 +456,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
case self::TYPE_UNSUBSCRIBED_FROM_OBJECT:
|
||||
case self::TYPE_FILE_HAS_OBJECT:
|
||||
case self::TYPE_CONTRIBUTED_TO_OBJECT:
|
||||
case self::TYPE_PROJECT_HAS_OBJECT:
|
||||
default:
|
||||
return '%s removed %d object(s): %s.';
|
||||
|
||||
|
@ -499,7 +487,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
return '%s updated members of %s.';
|
||||
case self::TYPE_MEMBER_OF_PROJ:
|
||||
case self::TYPE_COMMIT_HAS_PROJECT:
|
||||
case self::TYPE_OBJECT_HAS_PROJECT:
|
||||
return '%s updated projects of %s.';
|
||||
case self::TYPE_QUESTION_HAS_VOTING_USER:
|
||||
case self::TYPE_ANSWER_HAS_VOTING_USER:
|
||||
|
@ -538,7 +525,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
case self::TYPE_UNSUBSCRIBED_FROM_OBJECT:
|
||||
case self::TYPE_FILE_HAS_OBJECT:
|
||||
case self::TYPE_CONTRIBUTED_TO_OBJECT:
|
||||
case self::TYPE_PROJECT_HAS_OBJECT:
|
||||
default:
|
||||
return '%s updated objects of %s.';
|
||||
|
||||
|
|
Loading…
Reference in a new issue