Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F10750663
PhabricatorListener.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorListener.php
View Options
<?php
namespace
Nasqueron\Notifications\Listeners
;
use
Nasqueron\Notifications\Events\GitHubPayloadEvent
;
use
Nasqueron\Notifications\Jobs\NotifyNewCommitsToDiffusion
;
use
Illuminate\Events\Dispatcher
;
/**
* Listens to events Phabricator is interested by.
*/
class
PhabricatorListener
{
///
/// GitHub → Phabricator
///
/**
* Handles payload events.
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
public
function
onGitHubPayload
(
GitHubPayloadEvent
$event
)
:
void
{
if
(
$event
->
event
===
'push'
)
{
$this
->
notifyNewCommits
(
$event
);
}
}
/**
* Notifies Phabricator there are new commits to pull.
*
* @param GitHubPayloadEvent $event The GitHub payload event
*/
public
function
notifyNewCommits
(
GitHubPayloadEvent
$event
)
:
void
{
$job
=
new
NotifyNewCommitsToDiffusion
(
$event
->
door
,
$event
->
payload
->
repository
->
clone_url
);
$job
->
handle
();
}
///
/// Events listening
///
/**
* Registers the listeners for the subscriber.
*
* @param Dispatcher $events
*/
public
function
subscribe
(
Dispatcher
$events
)
:
void
{
$class
=
PhabricatorListener
::
class
;
$events
->
listen
(
GitHubPayloadEvent
::
class
,
"$class@onGitHubPayload"
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jul 27, 20:34 (3 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2760764
Default Alt Text
PhabricatorListener.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment