PusherAuthController   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A connectAction() 0 23 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\Controller;
4
5
use IrishDan\NotificationBundle\PusherChannel;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
10
class PusherAuthController extends Controller
11
{
12
    /**
13
     * Routing for private pusher channel authentication.
14
     */
15
    public function connectAction(Request $request)
16
    {
17
        $pusher = $this->get('notification.pusher_manager')->getPusherClient();
18
19
        $channelName = $request->get('channel_name');
20
        $socketId = $request->get('socket_id');
21
22
        $pusherChannel = new PusherChannel($channelName, $socketId);
23
24
        // Check if user should has access to the pusher channel.
25
        $this->denyAccessUnlessGranted('subscribe', $pusherChannel);
26
27
        // Creates a JSON encoded string.
28
        $responseBody = $pusher->socket_auth($channelName, $socketId);
29
30
        return new Response(
31
            $responseBody,
32
            '200',
33
            [
34
                'Content-Type' => 'application/json',
35
            ]
36
        );
37
    }
38
}
39