From fc1c36106daf8e4f0c5866ce6e80c3c6015c43ca Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 26 Nov 2015 06:07:18 -0800 Subject: [PATCH] Pass recently applied transactions to HeraldAdapters Summary: Ref T9851. See T9860. This adds a missing capability to custom HeraldActions, to pave the way for removing the obsolete/undesirable WILLEDITTASK and DIDEDITTASK events. Test Plan: See T9860 for a replacement action. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9851 Differential Revision: https://secure.phabricator.com/D14575 --- .../herald/adapter/HeraldAdapter.php | 31 +++++++++++++++++++ ...habricatorApplicationTransactionEditor.php | 9 ++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php index bec6677230..c7239438c6 100644 --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -29,6 +29,7 @@ abstract class HeraldAdapter extends Phobject { private $contentSource; private $isNewObject; private $applicationEmail; + private $appliedTransactions = array(); private $queuedTransactions = array(); private $emailPHIDs = array(); private $forcedEmailPHIDs = array(); @@ -121,6 +122,36 @@ abstract class HeraldAdapter extends Phobject { return !empty($applications); } + + /** + * Set the list of transactions which just took effect. + * + * These transactions are set by @{class:PhabricatorApplicationEditor} + * automatically, before it invokes Herald. + * + * @param list List of transactions. + * @return this + */ + final public function setAppliedTransactions(array $xactions) { + assert_instances_of($xactions, 'PhabricatorApplicationTransaction'); + $this->appliedTransactions = $xactions; + return $this; + } + + + /** + * Get a list of transactions which just took effect. + * + * When an object is edited normally, transactions are applied and then + * Herald executes. You can call this method to examine the transactions + * if you want to react to them. + * + * @return list List of transactions. + */ + final public function getAppliedTransactions() { + return $this->appliedTransactions; + } + public function queueTransaction($transaction) { $this->queuedTransactions[] = $transaction; } diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 07c1b983fd..8fdcb8c925 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -2867,12 +2867,15 @@ abstract class PhabricatorApplicationTransactionEditor PhabricatorLiskDAO $object, array $xactions) { - $adapter = $this->buildHeraldAdapter($object, $xactions); - $adapter->setContentSource($this->getContentSource()); - $adapter->setIsNewObject($this->getIsNewObject()); + $adapter = $this->buildHeraldAdapter($object, $xactions) + ->setContentSource($this->getContentSource()) + ->setIsNewObject($this->getIsNewObject()) + ->setAppliedTransactions($xactions); + if ($this->getApplicationEmail()) { $adapter->setApplicationEmail($this->getApplicationEmail()); } + $xscript = HeraldEngine::loadAndApplyRules($adapter); $this->setHeraldAdapter($adapter);