diff --git a/src/workflow/ArcanistBaseWorkflow.php b/src/workflow/ArcanistBaseWorkflow.php index 52512855..a5afc101 100644 --- a/src/workflow/ArcanistBaseWorkflow.php +++ b/src/workflow/ArcanistBaseWorkflow.php @@ -1315,4 +1315,15 @@ abstract class ArcanistBaseWorkflow { return $parser; } + protected function dispatchEvent($type, array $data) { + $data += array( + 'workflow' => $this, + ); + + $event = new PhutilEvent($type, $data); + PhutilEventEngine::dispatchEvent($event); + + return $event; + } + } diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php index eb4a18c9..8fce0a97 100644 --- a/src/workflow/ArcanistCommitWorkflow.php +++ b/src/workflow/ArcanistCommitWorkflow.php @@ -135,14 +135,11 @@ EOTEXT 'edit' => false, )); - $event = new PhutilEvent( + $event = $this->dispatchEvent( ArcanistEventType::TYPE_COMMIT_WILLCOMMITSVN, array( 'message' => $message, - 'workflow' => $this, - ) - ); - PhutilEventEngine::dispatchEvent($event); + )); $message = $event->getValue('message'); diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 40dba22c..6d78f4c9 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -383,8 +383,9 @@ EOTEXT $commit_message = $this->buildCommitMessage(); - PhutilEventEngine::dispatchEvent( - new PhutilEvent(ArcanistEventType::TYPE_DIFF_DIDBUILDMESSAGE)); + $this->dispatchEvent( + ArcanistEventType::TYPE_DIFF_DIDBUILDMESSAGE, + array()); if (!$this->shouldOnlyCreateDiff()) { $revision = $this->buildRevisionFromCommitMessage($commit_message); @@ -430,14 +431,13 @@ EOTEXT $this->diffID = $diff_info['diffid']; - $event = new PhutilEvent( + $event = $this->dispatchEvent( ArcanistEventType::TYPE_DIFF_WASCREATED, array( 'diffID' => $diff_info['diffid'], 'lintResult' => $lint_result, 'unitResult' => $unit_result, )); - PhutilEventEngine::dispatchEvent($event); $this->updateLintDiffProperty(); $this->updateUnitDiffProperty(); @@ -2273,26 +2273,22 @@ EOTEXT } private function dispatchWillCreateRevisionEvent(array $fields) { - $event = new PhutilEvent( + $event = $this->dispatchEvent( ArcanistEventType::TYPE_REVISION_WILLCREATEREVISION, array( 'specification' => $fields, )); - PhutilEventEngine::dispatchEvent($event); - return $event->getValue('specification'); } private function dispatchWillBuildEvent(array $fields) { - $event = new PhutilEvent( + $event = $this->dispatchEvent( ArcanistEventType::TYPE_DIFF_WILLBUILDMESSAGE, array( 'fields' => $fields, )); - PhutilEventEngine::dispatchEvent($event); - return $event->getValue('fields'); }