Data.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Integration\Helper;
  7. use Magento\Integration\Model\Integration as IntegrationModel;
  8. class Data extends \Magento\Framework\App\Helper\AbstractHelper
  9. {
  10. /**
  11. * Make ACL resource array compatible with jQuery jsTree component.
  12. *
  13. * @param array $resources
  14. * @return array
  15. */
  16. public function mapResources(array $resources)
  17. {
  18. $output = [];
  19. foreach ($resources as $resource) {
  20. $item = [];
  21. $item['attr']['data-id'] = $resource['id'];
  22. $item['data'] = __($resource['title']);
  23. $item['children'] = [];
  24. if (isset($resource['children'])) {
  25. $item['state'] = 'open';
  26. $item['children'] = $this->mapResources($resource['children']);
  27. }
  28. $output[] = $item;
  29. }
  30. return $output;
  31. }
  32. /**
  33. * Check if integration is created using config file
  34. *
  35. * @param array $integrationData
  36. * @return bool true if integration is created using Config file
  37. */
  38. public function isConfigType($integrationData)
  39. {
  40. return isset(
  41. $integrationData[IntegrationModel::SETUP_TYPE]
  42. ) && $integrationData[IntegrationModel::SETUP_TYPE] == IntegrationModel::TYPE_CONFIG;
  43. }
  44. }