src/EventListener/RequestListener.php
private function handleSnsNotifications(GetResponseEvent $event) {
		$notification = json_decode((string) $event->getRequest()->getContent(), true);

		$type = $event->getRequest()->headers->get('x-amz-sns-message-type');

		$metadata = [
			'Type'      => $notification['Type'],
			'TopicArn'  => $notification['TopicArn'],
			'Timestamp' => $notification['Timestamp'],
		];

		if ($type === 'Notification') {

			// We put the queue name in the Subject field
			$queue               = $notification['Subject'];
			$metadata['Subject'] = $queue;

			$notification = new Notification(
				$notification['MessageId'],
				$notification['Message'],
				$metadata
			);

			$this->dispatcher->dispatch(
				Events::Notification($queue),
				new NotificationEvent($queue, NotificationEvent::TYPE_MESSAGE, $notification)
			);

			return "SNS Message Notification Received.";
		}

		// For subscription notifications, we need to parse the Queue from
		// the Topic ARN
		$arnParts = explode(':', $notification['TopicArn']);
		$last     = end($arnParts);
		$queue    = str_replace('qpush_', '', $last);

		// Get the token for the Subscription Confirmation
		$metadata['Token'] = $notification['Token'];

		$notification = new Notification(
			$notification['MessageId'],
			$notification['Message'],
			$metadata
		);

		$this->dispatcher->dispatch(
			Events::Notification($queue),
			new NotificationEvent($queue, NotificationEvent::TYPE_SUBSCRIPTION, $notification)
		);

		return "SNS Subscription Confirmation Received.";
	}
private function handleSnsNotifications(GetResponseEvent $event) {
		$notification = json_decode((string) $event->getRequest()->getContent(), true);

		$type = $event->getRequest()->headers->get('x-amz-sns-message-type');

		$metadata = [
			'Type'      => $notification['Type'],
			'TopicArn'  => $notification['TopicArn'],
			'Timestamp' => $notification['Timestamp'],
		];

		if ($type === 'Notification') {

			// We put the queue name in the Subject field
			$queue               = $notification['Subject'];
			$metadata['Subject'] = $queue;

			$notification = new Notification(
				$notification['MessageId'],
				$notification['Message'],
				$metadata
			);

			$this->dispatcher->dispatch(
				Events::Notification($queue),
				new NotificationEvent($queue, NotificationEvent::TYPE_MESSAGE, $notification)
			);

			return "SNS Message Notification Received.";
		}

		// For subscription notifications, we need to parse the Queue from
		// the Topic ARN
		$arnParts = explode(':', $notification['TopicArn']);
		$last     = end($arnParts);
		$queue    = str_replace('qpush_', '', $last);

		// Get the token for the Subscription Confirmation
		$metadata['Token'] = $notification['Token'];

		$notification = new Notification(
			$notification['MessageId'],
			$notification['Message'],
			$metadata
		);

		$this->dispatcher->dispatch(
			Events::Notification($queue),
			new NotificationEvent($queue, NotificationEvent::TYPE_SUBSCRIPTION, $notification)
		);

		return "SNS Subscription Confirmation Received.";
	}
private function handleSnsNotifications ( GetResponseEvent $ event ) { $ notification = json_decode ( ( string ) $ event -> getRequest ( ) -> getContent ( ) , true ) ; $ type = $ event -> getRequest ( ) -> headers -> get ( 'x-amz-sns-message-type' ) ; $ metadata = [ 'Type' => $ notification [ 'Type' ] , 'TopicArn' => $ notification [ 'TopicArn' ] , 'Timestamp' => $ notification [ 'Timestamp' ] , ] ; if ( $ type === 'Notification' ) { // We put the queue name in the Subject field $ queue = $ notification [ 'Subject' ] ; $ metadata [ 'Subject' ] = $ queue ; $ notification = new Notification ( $ notification [ 'MessageId' ] , $ notification [ 'Message' ] , $ metadata ) ; $ this -> dispatcher -> dispatch ( Events :: Notification ( $ queue ) , new NotificationEvent ( $ queue , NotificationEvent :: TYPE_MESSAGE , $ notification ) ) ; return "SNS Message Notification Received." ; } // For subscription notifications, we need to parse the Queue from // the Topic ARN $ arnParts = explode ( ':' , $ notification [ 'TopicArn' ] ) ; $ last = end ( $ arnParts ) ; $ queue = str_replace ( 'qpush_' , '' , $ last ) ; // Get the token for the Subscription Confirmation $ metadata [ 'Token' ] = $ notification [ 'Token' ] ; $ notification = new Notification ( $ notification [ 'MessageId' ] , $ notification [ 'Message' ] , $ metadata ) ; $ this -> dispatcher -> dispatch ( Events :: Notification ( $ queue ) , new NotificationEvent ( $ queue , NotificationEvent :: TYPE_SUBSCRIPTION , $ notification ) ) ; return "SNS Subscription Confirmation Received." ; }
Handles Notifications sent from AWS SNS

@param GetResponseEvent $event The Kernel Request's GetResponseEvent
@return string
Handles Notifications sent from AWS SNS