From 1e31f4d1dd8cf22784421ca455b362bfe9c85314 Mon Sep 17 00:00:00 2001 From: iglocska Date: Wed, 1 Dec 2021 14:25:34 +0100 Subject: [PATCH] new: [ACL Helper] check access for controller / action pair for given user - accesible everywhere in the UI --- src/View/AppView.php | 1 + src/View/Helper/ACLHelper.php | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/View/Helper/ACLHelper.php diff --git a/src/View/AppView.php b/src/View/AppView.php index 7636a87..9018168 100644 --- a/src/View/AppView.php +++ b/src/View/AppView.php @@ -44,5 +44,6 @@ class AppView extends View $this->loadHelper('FormFieldMassage'); $this->loadHelper('Paginator', ['templates' => 'cerebrate-pagination-templates']); $this->loadHelper('Tags.Tag'); + $this->loadHelper('ACL'); } } diff --git a/src/View/Helper/ACLHelper.php b/src/View/Helper/ACLHelper.php new file mode 100644 index 0000000..e563e82 --- /dev/null +++ b/src/View/Helper/ACLHelper.php @@ -0,0 +1,25 @@ +roleAccess)) { + $this->roleAccess = $this->getView()->get('roleAccess'); + } + if ( + in_array($action, $this->roleAccess['*']) || + (isset($this->roleAccess[$controller]) && in_array($action, $this->roleAccess[$controller])) + ) { + return true; + } else { + return false; + } + } +}