|
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
|
|
|
* User controller class. |
|
28
|
|
|
*/ |
|
29
|
|
View Code Duplication |
abstract class AbstractUserController extends AbstractController |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* This is the default action handling the index 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_OVERVIEW; |
|
47
|
|
|
if (!$this->hasPermission($this->name . '::', '::', $permLevel)) { |
|
48
|
|
|
throw new AccessDeniedException(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
// redirect to view action |
|
52
|
|
|
$routeArea = ''; |
|
53
|
|
|
|
|
54
|
|
|
return $this->redirectToRoute('zikularoutesmodule_' . strtolower($objectType) . '_' . $routeArea . 'view'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
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.