From 66d19602e9627b2c446dd5445ff62bfbc2eea2b6 Mon Sep 17 00:00:00 2001 From: Aneurin Barker Snook Date: Wed, 4 May 2016 10:12:21 +0100 Subject: [PATCH] don't hardcode the Magento_Backend::admin index --- .../Integration/Activate/Permissions/Tab/Webapi.php | 12 ++++++++++-- .../Block/Adminhtml/Integration/Edit/Tab/Webapi.php | 6 +++++- app/code/Magento/User/Block/Role/Tab/Edit.php | 10 +++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php index 81b558f3267e2..0c108b11a4049 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php @@ -148,7 +148,11 @@ public function isEverythingAllowed() public function getResourcesTreeJson() { $resources = $this->_resourceProvider->getAclResources(); - $aclResourcesTree = $this->_integrationData->mapResources($resources[1]['children']); + $configResource = array_filter($resources, function($node) { + return $node['id'] == 'Magento_Backend::admin'; + }); + $configResource = reset($configResource); + $aclResourcesTree = $this->_integrationData->mapResources($configResource['children']); return $this->encoder->encode($aclResourcesTree); } @@ -167,7 +171,11 @@ public function getSelectedResourcesJson() $selectedResources = $this->_selectedResources; if ($this->isEverythingAllowed()) { $resources = $this->_resourceProvider->getAclResources(); - $selectedResources = $this->_getAllResourceIds($resources[1]['children']); + $configResource = array_filter($resources, function($node) { + return $node['id'] == 'Magento_Backend::admin'; + }); + $configResource = reset($configResource); + $selectedResources = $this->_getAllResourceIds($configResource['children']); } return $this->encoder->encode($selectedResources); } diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php index ecd361aaadf94..d6eb51cd27914 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php @@ -176,8 +176,12 @@ public function isEverythingAllowed() public function getTree() { $resources = $this->aclResourceProvider->getAclResources(); + $configResource = array_filter($resources, function($node) { + return $node['id'] == 'Magento_Backend::admin'; + }); + $configResource = reset($configResource); $rootArray = $this->integrationData->mapResources( - isset($resources[1]['children']) ? $resources[1]['children'] : [] + isset($configResource['children']) ? $configResource['children'] : [] ); return $rootArray; } diff --git a/app/code/Magento/User/Block/Role/Tab/Edit.php b/app/code/Magento/User/Block/Role/Tab/Edit.php index 81fe19eeff706..caf8a60007675 100644 --- a/app/code/Magento/User/Block/Role/Tab/Edit.php +++ b/app/code/Magento/User/Block/Role/Tab/Edit.php @@ -198,9 +198,13 @@ public function getSelectedResources() */ public function getTree() { - $resources = $this->_aclResourceProvider->getAclResources(); - $rootArray = $this->_integrationData->mapResources( - isset($resources[1]['children']) ? $resources[1]['children'] : [] + $resources = $this->aclResourceProvider->getAclResources(); + $configResource = array_filter($resources, function($node) { + return $node['id'] == 'Magento_Backend::admin'; + }); + $configResource = reset($configResource); + $rootArray = $this->integrationData->mapResources( + isset($configResource['children']) ? $configResource['children'] : [] ); return $rootArray; }