Converter.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Integration\Model\Config;
  7. /**
  8. * Converter of integration.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 KEY_EMAIL = 'email';
  18. const KEY_AUTHENTICATION_ENDPOINT_URL = 'endpoint_url';
  19. const KEY_IDENTITY_LINKING_URL = 'identity_link_url';
  20. /**#@-*/
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function convert($source)
  25. {
  26. $result = [];
  27. /** @var \DOMNodeList $integrations */
  28. $integrations = $source->getElementsByTagName('integration');
  29. /** @var \DOMElement $integration */
  30. foreach ($integrations as $integration) {
  31. if ($integration->nodeType != XML_ELEMENT_NODE) {
  32. continue;
  33. }
  34. $integrationName = $integration->attributes->getNamedItem('name')->nodeValue;
  35. $result[$integrationName] = [];
  36. /** @var \DOMElement $email */
  37. $email = $integration->getElementsByTagName('email')->item(0)->nodeValue;
  38. $result[$integrationName][self::KEY_EMAIL] = $email;
  39. if ($integration->getElementsByTagName('endpoint_url')->length) {
  40. /** @var \DOMElement $endpointUrl */
  41. $endpointUrl = $integration->getElementsByTagName('endpoint_url')->item(0)->nodeValue;
  42. $result[$integrationName][self::KEY_AUTHENTICATION_ENDPOINT_URL] = $endpointUrl;
  43. }
  44. if ($integration->getElementsByTagName('identity_link_url')->length) {
  45. /** @var \DOMElement $identityLinkUrl */
  46. $identityLinkUrl = $integration->getElementsByTagName('identity_link_url')->item(0)->nodeValue;
  47. $result[$integrationName][self::KEY_IDENTITY_LINKING_URL] = $identityLinkUrl;
  48. }
  49. }
  50. return $result;
  51. }
  52. }