Converter.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Integration\Model\Config\Integration;
  7. /**
  8. * Converter of api.xml content into array format.
  9. *
  10. * @deprecated 100.1.0
  11. */
  12. class Converter implements \Magento\Framework\Config\ConverterInterface
  13. {
  14. /**#@+
  15. * Array keys for config internal representation.
  16. */
  17. const API_RESOURCES = 'resource';
  18. const API_RESOURCE_NAME = 'name';
  19. /**#@-*/
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function convert($source)
  24. {
  25. $result = [];
  26. /** @var \DOMNodeList $integrations */
  27. $integrations = $source->getElementsByTagName('integration');
  28. /** @var \DOMElement $integration */
  29. foreach ($integrations as $integration) {
  30. if ($integration->nodeType != XML_ELEMENT_NODE) {
  31. continue;
  32. }
  33. $integrationName = $integration->attributes->getNamedItem('name')->nodeValue;
  34. $result[$integrationName] = [];
  35. $result[$integrationName][self::API_RESOURCES] = [];
  36. /** @var \DOMNodeList $resources */
  37. $resources = $integration->getElementsByTagName('resource');
  38. /** @var \DOMElement $resource */
  39. foreach ($resources as $resource) {
  40. if ($resource->nodeType != XML_ELEMENT_NODE) {
  41. continue;
  42. }
  43. $resource = $resource->attributes->getNamedItem('name')->nodeValue;
  44. $result[$integrationName][self::API_RESOURCES][] = $resource;
  45. }
  46. }
  47. return $result;
  48. }
  49. }