1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

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
This commit is contained in:
epriestley 2015-11-26 06:07:18 -08:00
parent 8c016b20d2
commit fc1c36106d
2 changed files with 37 additions and 3 deletions

View file

@ -29,6 +29,7 @@ abstract class HeraldAdapter extends Phobject {
private $contentSource; private $contentSource;
private $isNewObject; private $isNewObject;
private $applicationEmail; private $applicationEmail;
private $appliedTransactions = array();
private $queuedTransactions = array(); private $queuedTransactions = array();
private $emailPHIDs = array(); private $emailPHIDs = array();
private $forcedEmailPHIDs = array(); private $forcedEmailPHIDs = array();
@ -121,6 +122,36 @@ abstract class HeraldAdapter extends Phobject {
return !empty($applications); 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<PhabricatorApplicationTransaction> 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<PhabricatorApplicationTransaction> List of transactions.
*/
final public function getAppliedTransactions() {
return $this->appliedTransactions;
}
public function queueTransaction($transaction) { public function queueTransaction($transaction) {
$this->queuedTransactions[] = $transaction; $this->queuedTransactions[] = $transaction;
} }

View file

@ -2867,12 +2867,15 @@ abstract class PhabricatorApplicationTransactionEditor
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
array $xactions) { array $xactions) {
$adapter = $this->buildHeraldAdapter($object, $xactions); $adapter = $this->buildHeraldAdapter($object, $xactions)
$adapter->setContentSource($this->getContentSource()); ->setContentSource($this->getContentSource())
$adapter->setIsNewObject($this->getIsNewObject()); ->setIsNewObject($this->getIsNewObject())
->setAppliedTransactions($xactions);
if ($this->getApplicationEmail()) { if ($this->getApplicationEmail()) {
$adapter->setApplicationEmail($this->getApplicationEmail()); $adapter->setApplicationEmail($this->getApplicationEmail());
} }
$xscript = HeraldEngine::loadAndApplyRules($adapter); $xscript = HeraldEngine::loadAndApplyRules($adapter);
$this->setHeraldAdapter($adapter); $this->setHeraldAdapter($adapter);