summaryrefslogtreecommitdiff
path: root/app/Http/Controllers/AdminModuleController.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Http/Controllers/AdminModuleController.php')
-rw-r--r--app/Http/Controllers/AdminModuleController.php67
1 files changed, 35 insertions, 32 deletions
diff --git a/app/Http/Controllers/AdminModuleController.php b/app/Http/Controllers/AdminModuleController.php
index 0db83cd029..26cee639ae 100644
--- a/app/Http/Controllers/AdminModuleController.php
+++ b/app/Http/Controllers/AdminModuleController.php
@@ -25,42 +25,45 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-class AdminModuleController extends AdminController {
+class AdminModuleController extends AdminController
+{
- /**
- * @param Request $request
- * @return Response
- */
- public function action(Request $request): Response {
- /** @var User $user */
- $user = $request->attributes->get('user');
+ /**
+ * @param Request $request
+ *
+ * @return Response
+ */
+ public function action(Request $request): Response
+ {
+ /** @var User $user */
+ $user = $request->attributes->get('user');
- $module_name = $request->get('module');
+ $module_name = $request->get('module');
- // Check that the module is enabled.
- // The module itself will need to check any tree-level access,
- // which may be different for each component (tab, menu, etc.) of the module.
- $module = Module::getModuleByName($module_name);
+ // Check that the module is enabled.
+ // The module itself will need to check any tree-level access,
+ // which may be different for each component (tab, menu, etc.) of the module.
+ $module = Module::getModuleByName($module_name);
- // We'll call a function such as Module::getFooBarAction()
- $verb = strtolower($request->getMethod());
- $action = $request->get('action');
- $method = $verb . $action . 'Action';
+ // We'll call a function such as Module::getFooBarAction()
+ $verb = strtolower($request->getMethod());
+ $action = $request->get('action');
+ $method = $verb . $action . 'Action';
- // Actions with "Admin" in the name are for administrators only.
- if (strpos($action, 'Admin') !== false && !Auth::isAdmin($user)) {
- throw new AccessDeniedHttpException;
- }
+ // Actions with "Admin" in the name are for administrators only.
+ if (strpos($action, 'Admin') !== false && !Auth::isAdmin($user)) {
+ throw new AccessDeniedHttpException;
+ }
- if (method_exists($module, $method)) {
- $response = $module->$method($request);
- if ($response instanceof Response) {
- return $response;
- } else {
- return $this->viewResponse($response->name, $response->data);
- }
- } else {
- throw new NotFoundHttpException('Module not found');
- }
- }
+ if (method_exists($module, $method)) {
+ $response = $module->$method($request);
+ if ($response instanceof Response) {
+ return $response;
+ } else {
+ return $this->viewResponse($response->name, $response->data);
+ }
+ } else {
+ throw new NotFoundHttpException('Module not found');
+ }
+ }
}