Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F52699846
AMQPEventListener.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
AMQPEventListener.php
View Options
<?php
namespace
Nasqueron\Notifications\Listeners
;
use
Nasqueron\Notifications\Events\NotificationEvent
;
use
Nasqueron\Notifications\Jobs\SendMessageToBroker
;
use
Nasqueron\Notifications\Notifications\Notification
;
use
Illuminate\Support\Facades\Config
;
class
AMQPEventListener
{
///
/// Notifications
///
/**
* Handles a notification event.
*
* @param NotificationEvent $event
*/
public
function
handle
(
NotificationEvent
$event
)
:
void
{
$this
->
sendNotification
(
$event
->
notification
);
}
protected
static
function
getNotificationRoutingKey
(
Notification
$notification
)
:
string
{
$keyParts
=
[
$notification
->
project
,
$notification
->
group
,
$notification
->
service
,
$notification
->
type
,
];
return
strtolower
(
implode
(
'.'
,
$keyParts
));
}
/**
* Sends the notification to the broker target for distilled notifications.
*
* @param Notification The notification to send
*/
protected
function
sendNotification
(
Notification
$notification
)
:
void
{
$target
=
Config
::
get
(
'broker.targets.notifications'
);
$routingKey
=
static
::
getNotificationRoutingKey
(
$notification
);
$message
=
json_encode
(
$notification
);
$job
=
new
SendMessageToBroker
(
$target
,
$routingKey
,
$message
);
$job
->
handle
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Oct 6, 02:35 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4153659
Default Alt Text
AMQPEventListener.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment