mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 14:51:06 +01:00
Added willEditTask and didEditTask for Differential.
Summary: Added constants to PhabricatorEventType. Modified DifferentialRevisionEditor and DifferentialCommentEditor. Test Plan: Created a revision. Edited and made a comment on that revision. It's updating as usual. I think nothing broke may be it's working. Let me know if I have done it correclty. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, AnhNhan Maniphest Tasks: T2899 Differential Revision: https://secure.phabricator.com/D5869
This commit is contained in:
parent
38778a8b84
commit
473a2c3b31
4 changed files with 76 additions and 1 deletions
|
@ -56,6 +56,20 @@ final class DifferentialRevisionEditController extends DifferentialController {
|
|||
}
|
||||
|
||||
if (!$errors) {
|
||||
$is_new = !$revision->getID();
|
||||
$user = $request->getUser();
|
||||
|
||||
$event = new PhabricatorEvent(
|
||||
PhabricatorEventType::TYPE_DIFFERENTIAL_WILLEDITREVISION,
|
||||
array(
|
||||
'revision' => $revision,
|
||||
'new' => $is_new,
|
||||
));
|
||||
|
||||
$event->setUser($user);
|
||||
$event->setAphrontRequest($request);
|
||||
PhutilEventEngine::dispatchEvent($event);
|
||||
|
||||
$editor = new DifferentialRevisionEditor($revision);
|
||||
$editor->setActor($request->getUser());
|
||||
if ($diff) {
|
||||
|
@ -64,6 +78,16 @@ final class DifferentialRevisionEditController extends DifferentialController {
|
|||
$editor->setAuxiliaryFields($aux_fields);
|
||||
$editor->save();
|
||||
|
||||
$event = new PhabricatorEvent(
|
||||
PhabricatorEventType::TYPE_DIFFERENTIAL_DIDEDITREVISION,
|
||||
array(
|
||||
'revision' => $revision,
|
||||
'new' => $is_new,
|
||||
));
|
||||
$event->setUser($user);
|
||||
$event->setAphrontRequest($request);
|
||||
PhutilEventEngine::dispatchEvent($event);
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/D'.$revision->getID());
|
||||
}
|
||||
|
|
|
@ -492,6 +492,18 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
|
|||
$actor_phid);
|
||||
}
|
||||
|
||||
$is_new = !$revision->getID();
|
||||
|
||||
$event = new PhabricatorEvent(
|
||||
PhabricatorEventType::TYPE_DIFFERENTIAL_WILLEDITREVISION,
|
||||
array(
|
||||
'revision' => $revision,
|
||||
'new' => $is_new,
|
||||
));
|
||||
|
||||
$event->setUser($actor);
|
||||
PhutilEventEngine::dispatchEvent($event);
|
||||
|
||||
$comment = id(new DifferentialComment())
|
||||
->setAuthorPHID($actor_phid)
|
||||
->setRevisionID($revision->getID())
|
||||
|
@ -546,6 +558,15 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
|
|||
|
||||
$comment->setMetadata($metadata);
|
||||
$comment->save();
|
||||
|
||||
$event = new PhabricatorEvent(
|
||||
PhabricatorEventType::TYPE_DIFFERENTIAL_DIDEDITREVISION,
|
||||
array(
|
||||
'revision' => $revision,
|
||||
'new' => $is_new,
|
||||
));
|
||||
$event->setUser($actor);
|
||||
PhutilEventEngine::dispatchEvent($event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -204,6 +204,34 @@ doesn't need to be reviewed) or not. Data available on this event:
|
|||
- ##is_generated## Boolean indicating if this file should be treated as
|
||||
generated.
|
||||
|
||||
== Differential: Will Edit Revision ==
|
||||
|
||||
The constant for this event is
|
||||
`PhabricatorEventType::TYPE_DIFFERENTIAL_WILLEDITREVISION`.
|
||||
|
||||
This event is dispatched before a revision is edited, and allows you to
|
||||
respond to or alter the edit. Data available on this event:
|
||||
|
||||
- ##revision## The @{class:DifferentialRevision} being edited.
|
||||
- ##new## A boolean indicating if this revision is being created.
|
||||
|
||||
This is similar to the next event (did edit revision) but occurs before the edit
|
||||
begins.
|
||||
|
||||
== Differential: Did Edit Revision ==
|
||||
|
||||
The constant for this event is
|
||||
`PhabricatorEventType::TYPE_DIFFERENTIAL_DIDEDITREVISION`.
|
||||
|
||||
This event is dispatched after a revision is edited, and allows you to
|
||||
react to the edit. Data available on this event:
|
||||
|
||||
- ##revision## The @{class:DifferentialRevision} being edited.
|
||||
- ##new## A boolean indicating if this revision is being created.
|
||||
|
||||
This is similar to the previous event (will edit revision) but occurs after the
|
||||
edit completes.
|
||||
|
||||
== Diffusion: Did Discover Commit ==
|
||||
|
||||
The constant for this event is
|
||||
|
@ -336,4 +364,4 @@ If you're having problems with your listener, try these steps:
|
|||
Continue by:
|
||||
|
||||
- taking a look at @{class:PhabricatorExampleEventListener}; or
|
||||
- building a library with @{article:libphutil Libraries User Guide}.
|
||||
- building a library with @{article:libphutil Libraries User Guide}.
|
||||
|
|
|
@ -15,6 +15,8 @@ final class PhabricatorEventType extends PhutilEventType {
|
|||
|
||||
const TYPE_DIFFERENTIAL_WILLSENDMAIL = 'differential.willSendMail';
|
||||
const TYPE_DIFFERENTIAL_WILLMARKGENERATED = 'differential.willMarkGenerated';
|
||||
const TYPE_DIFFERENTIAL_WILLEDITREVISION = 'differential.willEditRevision';
|
||||
const TYPE_DIFFERENTIAL_DIDEDITREVISION = 'differential.didEditRevision';
|
||||
|
||||
const TYPE_DIFFUSION_DIDDISCOVERCOMMIT = 'diffusion.didDiscoverCommit';
|
||||
const TYPE_DIFFUSION_LOOKUPUSER = 'diffusion.lookupUser';
|
||||
|
|
Loading…
Reference in a new issue