From 83d1e3edb59b2d25bf62e6fa2e059d993c4ae57f Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Thu, 1 Jan 2015 11:15:34 +1100 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 4 + .../DifferentialRequiredSignaturesField.php | 2 +- .../editor/DifferentialTransactionEditor.php | 2 +- .../LegalpadObjectNeedsSignatureEdgeType.php | 102 ++++++++++++++++++ ...egalpadSignatureNeededByObjectEdgeType.php | 12 +++ .../edges/constants/PhabricatorEdgeConfig.php | 10 -- .../PhabricatorBaseEnglishTranslation.php | 2 +- 7 files changed, 121 insertions(+), 13 deletions(-) create mode 100644 src/applications/legalpad/edge/LegalpadObjectNeedsSignatureEdgeType.php create mode 100644 src/applications/legalpad/edge/LegalpadSignatureNeededByObjectEdgeType.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 947c9b99c5..cf8fc0b533 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/applications/differential/customfield/DifferentialRequiredSignaturesField.php b/src/applications/differential/customfield/DifferentialRequiredSignaturesField.php index 85dcc32d5a..2408daa27c 100644 --- a/src/applications/differential/customfield/DifferentialRequiredSignaturesField.php +++ b/src/applications/differential/customfield/DifferentialRequiredSignaturesField.php @@ -39,7 +39,7 @@ final class DifferentialRequiredSignaturesField $phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $revision->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_NEEDS_SIGNATURE); + LegalpadObjectNeedsSignatureEdgeType::EDGECONST); if ($phids) { diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php index a0981544b9..c8d9ce86ef 100644 --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -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) diff --git a/src/applications/legalpad/edge/LegalpadObjectNeedsSignatureEdgeType.php b/src/applications/legalpad/edge/LegalpadObjectNeedsSignatureEdgeType.php new file mode 100644 index 0000000000..dfc5843fd2 --- /dev/null +++ b/src/applications/legalpad/edge/LegalpadObjectNeedsSignatureEdgeType.php @@ -0,0 +1,102 @@ + 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: diff --git a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php index 85b718ec6b..c80d58fba5 100644 --- a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php +++ b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php @@ -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.',