Completed
Push — master ( 5bcd6a...b668e1 )
by Jim
04:48 queued 01:57
created

AbstractController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A denyAccessUnlessGranted() 0 6 3
1
<?php
2
3
/*
4
 * (c) Jim Martens <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace TwoMartens\Bundle\CoreBundle\Controller;
11
12
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
13
14
/**
15
 * Empowers ROLE_SUPER_ADMIN to do everything.
16
 *
17
 * Extends the denyAccessUnlessGranted method to check
18
 * if either provided role or ROLE_SUPER_ADMIN is granted.
19
 * If both are not granted it throws an exception.
20
 *
21
 * @author    Jim Martens <[email protected]>
22
 * @copyright 2013-2016 Jim Martens
23
 */
24
abstract class AbstractController extends Controller
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected function denyAccessUnlessGranted($attributes, $object = null, $message = 'Access Denied.')
30
    {
31
        if (!$this->isGranted($attributes, $object) && !$this->isGranted('ROLE_SUPER_ADMIN', $object)) {
32
            throw $this->createAccessDeniedException($message);
33
        }
34
    }
35
}
36