mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 09:20:58 +01:00
Modernize Legalpad edge types
Summary: Modernize Legalpad edges to subclass `PhabricatorEdgeType`. Largely based on D11045. Test Plan: # Created a Herald rule to require legal signatures on all diffs. # Created a new diff. # Saw the transaction string appear correctly. I wasn't able to check the inverse transaction because there is none. Also, I couldn't see any text on the feed (presumably, transactions authored by Herald do not generate feed items) Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Krenair, chad, epriestley Differential Revision: https://secure.phabricator.com/D11082
This commit is contained in:
parent
cae8c49745
commit
83d1e3edb5
7 changed files with 121 additions and 13 deletions
|
@ -950,8 +950,10 @@ phutil_register_library_map(array(
|
|||
'LegalpadDocumentSignatureVerificationController' => 'applications/legalpad/controller/LegalpadDocumentSignatureVerificationController.php',
|
||||
'LegalpadDocumentSignatureViewController' => 'applications/legalpad/controller/LegalpadDocumentSignatureViewController.php',
|
||||
'LegalpadMockMailReceiver' => 'applications/legalpad/mail/LegalpadMockMailReceiver.php',
|
||||
'LegalpadObjectNeedsSignatureEdgeType' => 'applications/legalpad/edge/LegalpadObjectNeedsSignatureEdgeType.php',
|
||||
'LegalpadReplyHandler' => 'applications/legalpad/mail/LegalpadReplyHandler.php',
|
||||
'LegalpadSchemaSpec' => 'applications/legalpad/storage/LegalpadSchemaSpec.php',
|
||||
'LegalpadSignatureNeededByObjectEdgeType' => 'applications/legalpad/edge/LegalpadSignatureNeededByObjectEdgeType.php',
|
||||
'LegalpadTransaction' => 'applications/legalpad/storage/LegalpadTransaction.php',
|
||||
'LegalpadTransactionComment' => 'applications/legalpad/storage/LegalpadTransactionComment.php',
|
||||
'LegalpadTransactionQuery' => 'applications/legalpad/query/LegalpadTransactionQuery.php',
|
||||
|
@ -4050,8 +4052,10 @@ phutil_register_library_map(array(
|
|||
'LegalpadDocumentSignatureVerificationController' => 'LegalpadController',
|
||||
'LegalpadDocumentSignatureViewController' => 'LegalpadController',
|
||||
'LegalpadMockMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||
'LegalpadObjectNeedsSignatureEdgeType' => 'PhabricatorEdgeType',
|
||||
'LegalpadReplyHandler' => 'PhabricatorMailReplyHandler',
|
||||
'LegalpadSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||
'LegalpadSignatureNeededByObjectEdgeType' => 'PhabricatorEdgeType',
|
||||
'LegalpadTransaction' => 'PhabricatorApplicationTransaction',
|
||||
'LegalpadTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||
'LegalpadTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
|
|
|
@ -39,7 +39,7 @@ final class DifferentialRequiredSignaturesField
|
|||
|
||||
$phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$revision->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_NEEDS_SIGNATURE);
|
||||
LegalpadObjectNeedsSignatureEdgeType::EDGECONST);
|
||||
|
||||
if ($phids) {
|
||||
|
||||
|
|
|
@ -1633,7 +1633,7 @@ final class DifferentialTransactionEditor
|
|||
|
||||
// If we still have something to trigger, add the edges.
|
||||
if ($legal_phids) {
|
||||
$edge_legal = PhabricatorEdgeConfig::TYPE_OBJECT_NEEDS_SIGNATURE;
|
||||
$edge_legal = LegalpadObjectNeedsSignatureEdgeType::EDGECONST;
|
||||
$xactions[] = id(new DifferentialTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $edge_legal)
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
final class LegalpadObjectNeedsSignatureEdgeType extends PhabricatorEdgeType {
|
||||
|
||||
const EDGECONST = 49;
|
||||
|
||||
public function getInverseEdgeConstant() {
|
||||
return LegalpadSignatureNeededByObjectEdgeType::EDGECONST;
|
||||
}
|
||||
|
||||
public function getTransactionAddString(
|
||||
$actor,
|
||||
$add_count,
|
||||
$add_edges) {
|
||||
|
||||
return pht(
|
||||
'%s added %s required legal document(s): %s.',
|
||||
$actor,
|
||||
$add_count,
|
||||
$add_edges);
|
||||
}
|
||||
|
||||
public function getTransactionRemoveString(
|
||||
$actor,
|
||||
$rem_count,
|
||||
$rem_edges) {
|
||||
|
||||
return pht(
|
||||
'%s removed %s required legal document(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 required legal document(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 required legal document(s) to %s: %s.',
|
||||
$actor,
|
||||
$add_count,
|
||||
$object,
|
||||
$add_edges);
|
||||
}
|
||||
|
||||
public function getFeedRemoveString(
|
||||
$actor,
|
||||
$object,
|
||||
$rem_count,
|
||||
$rem_edges) {
|
||||
|
||||
return pht(
|
||||
'%s removed %s required legal document(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 required legal document(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 LegalpadSignatureNeededByObjectEdgeType
|
||||
extends PhabricatorEdgeType {
|
||||
|
||||
const EDGECONST = 50;
|
||||
|
||||
public function getInverseEdgeConstant() {
|
||||
return LegalpadObjectNeedsSignatureEdgeType::EDGECONST;
|
||||
}
|
||||
|
||||
}
|
|
@ -46,9 +46,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
const TYPE_OBJECT_HAS_WATCHER = 47;
|
||||
const TYPE_WATCHER_HAS_OBJECT = 48;
|
||||
|
||||
const TYPE_OBJECT_NEEDS_SIGNATURE = 49;
|
||||
const TYPE_SIGNATURE_NEEDED_BY_OBJECT = 50;
|
||||
|
||||
/* !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! */
|
||||
|
||||
// HEY! DO NOT ADD NEW CONSTANTS HERE!
|
||||
|
@ -171,11 +168,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
|
||||
self::TYPE_OBJECT_HAS_WATCHER => self::TYPE_WATCHER_HAS_OBJECT,
|
||||
self::TYPE_WATCHER_HAS_OBJECT => self::TYPE_OBJECT_HAS_WATCHER,
|
||||
|
||||
self::TYPE_OBJECT_NEEDS_SIGNATURE =>
|
||||
self::TYPE_SIGNATURE_NEEDED_BY_OBJECT,
|
||||
self::TYPE_SIGNATURE_NEEDED_BY_OBJECT =>
|
||||
self::TYPE_OBJECT_NEEDS_SIGNATURE,
|
||||
);
|
||||
|
||||
return idx($map, $edge_type);
|
||||
|
@ -308,8 +300,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
return '%s added %d dashboard(s): %s.';
|
||||
case self::TYPE_OBJECT_HAS_WATCHER:
|
||||
return '%s added %d watcher(s): %s.';
|
||||
case self::TYPE_OBJECT_NEEDS_SIGNATURE:
|
||||
return '%s added %d required legal document(s): %s.';
|
||||
case self::TYPE_SUBSCRIBED_TO_OBJECT:
|
||||
case self::TYPE_UNSUBSCRIBED_FROM_OBJECT:
|
||||
case self::TYPE_FILE_HAS_OBJECT:
|
||||
|
|
|
@ -914,7 +914,7 @@ abstract class PhabricatorBaseEnglishTranslation
|
|||
),
|
||||
),
|
||||
|
||||
'%s added %d required legal document(s): %s.' => array(
|
||||
'%s added %s required legal document(s): %s.' => array(
|
||||
array(
|
||||
'%s added a required legal document: %3$s.',
|
||||
'%s added required legal documents: %3$s.',
|
||||
|
|
Loading…
Reference in a new issue