mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-07 09:17:35 +00:00
- update jquery.jstree to the lates version - adjust user roles to work with new tree - add adjustments for ACL tree in Integration - add data-id attribute to support MFTF tests - fix available resource filtering when "all enabled" - update locators in functional tests - fix ajax tree data load - fix media gallery - fix static tests - Changed assertion for new TreeJson format
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
namespace Magento\Integration\Helper;
|
|
|
|
use Magento\Integration\Model\Integration as IntegrationModel;
|
|
|
|
class Data extends \Magento\Framework\App\Helper\AbstractHelper
|
|
{
|
|
/**
|
|
* Make ACL resource array compatible with jQuery jsTree component.
|
|
*
|
|
* @param array $resources
|
|
* @param array $selectedResources
|
|
* @return array
|
|
*/
|
|
public function mapResources(array $resources, array $selectedResources = [])
|
|
{
|
|
$output = [];
|
|
foreach ($resources as $resource) {
|
|
$item = [];
|
|
$item['id'] = $resource['id'];
|
|
$item['li_attr']['data-id'] = $resource['id'];
|
|
$item['text'] = __($resource['title']);
|
|
$item['children'] = [];
|
|
$item['state']['selected'] = in_array($item['id'], $selectedResources) ?? false;
|
|
if (isset($resource['children'])) {
|
|
$item['state']['opened'] = true;
|
|
$item['children'] = $this->mapResources($resource['children'], $selectedResources);
|
|
}
|
|
$output[] = $item;
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Check if integration is created using config file
|
|
*
|
|
* @param array $integrationData
|
|
* @return bool true if integration is created using Config file
|
|
*/
|
|
public function isConfigType($integrationData)
|
|
{
|
|
return isset(
|
|
$integrationData[IntegrationModel::SETUP_TYPE]
|
|
) && $integrationData[IntegrationModel::SETUP_TYPE] == IntegrationModel::TYPE_CONFIG;
|
|
}
|
|
}
|