Skip to content

Commit

Permalink
MAGETWO-52555: [Github][PR] Don't hardcode the Magento_Backend::admin…
Browse files Browse the repository at this point in the history
… index #4396
  • Loading branch information
Alex Paliarush authored and Oleksii Korshenko committed Aug 12, 2016
1 parent ccf02f3 commit 6b51259
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,7 @@ public function isEverythingAllowed()
*/
public function getResourcesTreeJson()
{
$resources = $this->_resourceProvider->getAclResources();
$configResource = array_filter($resources, function($node) {
return $node['id'] == 'Magento_Backend::admin';
});
$configResource = reset($configResource);
$aclResourcesTree = $this->_integrationData->mapResources($configResource['children']);
$aclResourcesTree = $this->_integrationData->mapResources($this->getAclResources());

return $this->encoder->encode($aclResourcesTree);
}
Expand All @@ -170,16 +165,29 @@ public function getSelectedResourcesJson()
{
$selectedResources = $this->_selectedResources;
if ($this->isEverythingAllowed()) {
$resources = $this->_resourceProvider->getAclResources();
$configResource = array_filter($resources, function($node) {
return $node['id'] == 'Magento_Backend::admin';
});
$configResource = reset($configResource);
$selectedResources = $this->_getAllResourceIds($configResource['children']);
$selectedResources = $this->_getAllResourceIds($this->getAclResources());
}
return $this->encoder->encode($selectedResources);
}

/**
* Get lit of all ACL resources declared in the system.
*
* @return array
*/
private function getAclResources()
{
$resources = $this->_resourceProvider->getAclResources();
$configResource = array_filter(
$resources,
function ($node) {
return $node['id'] == 'Magento_Backend::admin';
}
);
$configResource = reset($configResource);
return isset($configResource['children']) ? $configResource['children'] : [];
}

/**
* Whether tree has any resources.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Magento\Integration\Block\Adminhtml\Integration\Edit\Tab;

use Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info;
use Magento\Integration\Controller\Adminhtml\Integration as IntegrationController;
use Magento\Integration\Model\Integration as IntegrationModel;

Expand Down Expand Up @@ -174,15 +173,25 @@ public function isEverythingAllowed()
* @return array
*/
public function getTree()
{
return $this->integrationData->mapResources($this->getAclResources());
}

/**
* Get lit of all ACL resources declared in the system.
*
* @return array
*/
private function getAclResources()
{
$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'] : []
$configResource = array_filter(
$resources,
function ($node) {
return $node['id'] == 'Magento_Backend::admin';
}
);
return $rootArray;
$configResource = reset($configResource);
return isset($configResource['children']) ? $configResource['children'] : [];
}
}
29 changes: 18 additions & 11 deletions app/code/Magento/User/Block/Role/Tab/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Magento\User\Block\Role\Tab;

use Magento\Framework\App\ObjectManager;
use Magento\User\Controller\Adminhtml\User\Role\SaveRole;

/**
Expand Down Expand Up @@ -93,7 +92,6 @@ public function __construct(
*/
public function setCoreRegistry(\Magento\Framework\Registry $coreRegistry)
{

$this->coreRegistry = $coreRegistry;
}

Expand All @@ -105,7 +103,6 @@ public function setCoreRegistry(\Magento\Framework\Registry $coreRegistry)
*/
public function getCoreRegistry()
{

if (!($this->coreRegistry instanceof \Magento\Framework\Registry)) {
return \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\Registry::class);
} else {
Expand Down Expand Up @@ -198,14 +195,24 @@ public function getSelectedResources()
*/
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($configResource['children']) ? $configResource['children'] : []
return $this->_integrationData->mapResources($this->getAclResources());
}

/**
* Get lit of all ACL resources declared in the system.
*
* @return array
*/
private function getAclResources()
{
$resources = $this->_aclResourceProvider->getAclResources();
$configResource = array_filter(
$resources,
function ($node) {
return $node['id'] == 'Magento_Backend::admin';
}
);
return $rootArray;
$configResource = reset($configResource);
return isset($configResource['children']) ? $configResource['children'] : [];
}
}

0 comments on commit 6b51259

Please sign in to comment.