Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F25243949
NotificationListener.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
NotificationListener.php
View Options
<?php
namespace
Nasqueron\Notifications\Listeners
;
use
Nasqueron\Notifications\Events\GitHubPayloadEvent
;
use
Nasqueron\Notifications\Events\NotificationEvent
;
use
Nasqueron\Notifications\Notifications\GitHubNotification
;
use
Event
;
class
NotificationListener
{
///
/// Distill GitHub payloads into notifications
///
/**
* Handles a GitHub payload event.
*
* @param GitHubPayloadEvent $event
* @return void
*/
public
function
onGitHubPayload
(
GitHubPayloadEvent
$event
)
{
$notification
=
$this
->
createNotification
(
$event
);
$event
=
new
NotificationEvent
(
$notification
);
Event
::
fire
(
$event
);
}
/**
* Creates a GitHub notification
*
* @param GitHubPayloadEvent $event
* @return Notification the notification
*/
protected
function
createNotification
(
GitHubPayloadEvent
$event
)
{
$notification
=
new
GitHubNotification
(
$event
->
door
,
// project
$event
->
event
,
// event type
$event
->
payload
// raw content
);
return
$notification
;
}
///
/// Events listening
///
/**
* Register the listeners for the subscriber.
*
* @param Illuminate\Events\Dispatcher $events
*/
public
function
subscribe
(
$events
)
{
$class
=
'Nasqueron
\N
otifications
\L
isteners
\N
otificationListener'
;
$events
->
listen
(
'Nasqueron
\N
otifications
\E
vents
\G
itHubPayloadEvent'
,
"$class@onGitHubPayload"
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Apr 9, 02:17 (5 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3595973
Default Alt Text
NotificationListener.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment