PluginProbe
User Access Manager / 2.3.16
User Access Manager v2.3.16
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Controller/Controller.php +27 -12 trunk2.3.16 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * Controller.php
4 + *
5 + * The Controller class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Controller;
@@ -4,11 +17,17 @@
4 17
5 18 namespace UserAccessManager\Controller;
6 19
7 20 use UserAccessManager\Config\WordpressConfig;
21 +use UserAccessManager\Controller\Backend\BackendController;
8 22 use UserAccessManager\Wrapper\Php;
9 23 use UserAccessManager\Wrapper\Wordpress;
10 24
25 +/**
26 + * Class Controller
27 + *
28 + * @package UserAccessManager\Controller
29 + */
11 30 abstract class Controller
12 31 {
13 32 use BaseControllerTrait {
14 33 render as traitRender;
@@ -15,9 +34,8 @@
15 34 }
16 35
17 36 public const ACTION_PARAMETER = 'uam_action';
18 37 public const ACTION_SUFFIX = 'Action';
19 - public const UAM_ERRORS = 'UAM_ERRORS';
20 38
21 39 protected ?string $updateMessage = null;
22 40
23 41 public function __construct(
@@ -62,13 +80,13 @@
62 80 }
63 81
64 82 protected function addErrorMessage(string $message): void
65 83 {
66 - if (isset($_SESSION[self::UAM_ERRORS]) === false) {
67 - $_SESSION[self::UAM_ERRORS] = [];
84 + if (isset($_SESSION[BackendController::UAM_ERRORS]) === false) {
85 + $_SESSION[BackendController::UAM_ERRORS] = [];
68 86 }
69 87
70 - $_SESSION[self::UAM_ERRORS][] = $message;
88 + $_SESSION[BackendController::UAM_ERRORS][] = $message;
71 89 }
72 90
73 91 public function getUpdateMessage(): ?string
74 92 {
@@ -79,18 +97,15 @@
79 97 {
80 98 return $this->updateMessage !== null;
81 99 }
82 100
83 - private function toCamelCase(string $snakeCaseName): string
84 - {
85 - $words = explode('_', $snakeCaseName);
86 - return array_shift($words).implode('', array_map('ucfirst', $words));
87 - }
88 -
89 101 protected function processAction(): void
90 102 {
91 - $requestedAction = (string) $this->getRequestParameter(self::ACTION_PARAMETER);
92 - $actionMethod = $this->toCamelCase($requestedAction).self::ACTION_SUFFIX;
103 + $postAction = (string) $this->getRequestParameter(self::ACTION_PARAMETER);
104 + $postActionSplit = explode('_', $postAction);
105 + $postAction = array_shift($postActionSplit);
106 + $postAction .= implode('', array_map('ucfirst', $postActionSplit));
107 + $actionMethod = $postAction.self::ACTION_SUFFIX;
93 108
94 109 if (method_exists($this, $actionMethod) === true) {
95 110 $this->{$actionMethod}();
96 111 }