Completed
Pull Request — master (#6)
by
unknown
02:35
created

MailgunController::cockpitAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Azine\MailgunWebhooksBundle\Controller;
3
4
use Azine\MailgunWebhooksBundle\Entity\Repositories\MailgunEventRepository;
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
/**
7
 * Mailgun controller.
8
 *
9
 */
10
11
class MailgunController extends Controller
12
{
13
14
    /**
15
     * Show Mailgun-Overview
16
     *
17
     */
18
    public function overviewAction()
19
    {
20
        $params = array();
21
        $params['importantEvents'] = $this->getRepository()->getImportantEvents(10);
22
        $params['events'] = sizeof($this->getRepository()->findAll());
23
        $params['bounced'] = sizeof($this->getRepository()->findBy(array('event' => 'bounced')));
24
        $params['dropped'] = sizeof($this->getRepository()->findBy(array('event' => 'dropped')));
25
        $params['complained'] = sizeof($this->getRepository()->findBy(array('event' => 'complained')));
26
        $params['unsubscribed'] = sizeof($this->getRepository()->findBy(array('event' => 'unsubscribed')));
27
        $params['unopened'] = $this->getRepository()->getEventCount(array('eventType' => 'unopened'));
28
        
29
        return $this->render('AzineMailgunWebhooksBundle::overview.html.twig', $params);
30
    }
31
32
    public function cockpitAction()
33
    {
34
        return $this->render('@AzineMailgunWebhooks/cockpit.html.twig', $this->get('azine_mailgun.cockpit_service')->getCockpitDataAsArray());
35
    }
36
37
    /**
38
     * Get the MailgunEvent Repository
39
     * @return MailgunEventRepository
40
     */
41
    private function getRepository()
42
    {
43
        return $this->getDoctrine()->getManager()->getRepository('AzineMailgunWebhooksBundle:MailgunEvent');
44
    }
45
46
}
47