Completed
Push — master ( 5247c6...b8f763 )
by Craig
10:35 queued 03:41
created

AbstractAdminController::indexAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 15
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Routes.
4
 *
5
 * @copyright Zikula contributors (Zikula)
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 * @author Zikula contributors <[email protected]>.
8
 * @link http://www.zikula.org
9
 * @link http://zikula.org
10
 * @version Generated by ModuleStudio 0.7.0 (http://modulestudio.de).
11
 */
12
13
namespace Zikula\RoutesModule\Controller\Base;
14
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
17
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
18
use Symfony\Component\HttpFoundation\RedirectResponse;
19
use ModUtil;
20
use RuntimeException;
21
use System;
22
use Zikula\Core\Controller\AbstractController;
23
use Zikula\Core\RouteUrl;
24
use Zikula\Core\Response\PlainResponse;
25
26
/**
27
 * Admin controller class.
28
 */
29 View Code Duplication
abstract class AbstractAdminController extends AbstractController
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
{
31
32
    /**
33
     * This is the default action handling the main area called without defining arguments.
34
     *
35
     * @param Request  $request      Current request instance
36
     *
37
     * @return mixed Output
38
     *
39
     * @throws AccessDeniedException Thrown if the user doesn't have required permissions
40
     */
41
    public function indexAction(Request $request)
42
    {
43
        // parameter specifying which type of objects we are treating
44
        $objectType = $request->query->getAlnum('ot', 'route');
45
        
46
        $permLevel = ACCESS_ADMIN;
47
        if (!$this->hasPermission($this->name . '::', '::', $permLevel)) {
48
            throw new AccessDeniedException();
49
        }
50
        
51
        // redirect to view action
52
        $routeArea = 'admin';
53
        
54
        return $this->redirectToRoute('zikularoutesmodule_' . strtolower($objectType) . '_' . $routeArea . 'view');
55
    }
56
57
}
58