Skip to content

Commit

Permalink
don't hardcode the Magento_Backend::admin index
Browse files Browse the repository at this point in the history
  • Loading branch information
annybs committed May 4, 2016
1 parent 981d1f4 commit 66d1960
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 7 additions & 3 deletions app/code/Magento/User/Block/Role/Tab/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 66d1960

Please sign in to comment.