LinksConfigProvider.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Ui\Model\UrlInput;
  8. /**
  9. * Returns information about allowed links
  10. */
  11. class LinksConfigProvider implements ConfigInterface
  12. {
  13. /**
  14. * @var array
  15. */
  16. private $linksConfiguration;
  17. /**
  18. * Object manager
  19. *
  20. * @var \Magento\Framework\ObjectManagerInterface
  21. */
  22. private $objectManager;
  23. /**
  24. * LinksProvider constructor.
  25. * @param array $linksConfiguration
  26. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  27. */
  28. public function __construct(
  29. array $linksConfiguration,
  30. \Magento\Framework\ObjectManagerInterface $objectManager
  31. ) {
  32. $this->linksConfiguration = $linksConfiguration;
  33. $this->objectManager = $objectManager;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function getConfig(): array
  39. {
  40. $config = [];
  41. foreach ($this->linksConfiguration as $linkName => $className) {
  42. $config[$linkName] = $this->createConfigProvider($className)->getConfig();
  43. }
  44. return $config;
  45. }
  46. /**
  47. * Create config provider
  48. *
  49. * @param string $instance
  50. * @return ConfigInterface
  51. */
  52. private function createConfigProvider($instance): ConfigInterface
  53. {
  54. return $this->objectManager->create($instance);
  55. }
  56. }