Placeholder.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Placeholder configuration values processor. Replace placeholders in configuration with config values
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Store\Model\Config\Processor;
  9. use Magento\Framework\App\Config\Spi\PostProcessorInterface;
  10. use Magento\Store\Model\Config\Placeholder as ConfigPlaceholder;
  11. /**
  12. * Placeholder configuration values processor. Replace placeholders in configuration with config values
  13. */
  14. class Placeholder implements PostProcessorInterface
  15. {
  16. /**
  17. * @var ConfigPlaceholder
  18. */
  19. private $configPlaceholder;
  20. /**
  21. * Placeholder constructor.
  22. * @param ConfigPlaceholder $configPlaceholder
  23. */
  24. public function __construct(ConfigPlaceholder $configPlaceholder)
  25. {
  26. $this->configPlaceholder = $configPlaceholder;
  27. }
  28. /**
  29. * @inheritdoc
  30. */
  31. public function process(array $data)
  32. {
  33. foreach ($data as $scope => &$scopeData) {
  34. if ($scope === 'default') {
  35. $scopeData = $this->configPlaceholder->process($scopeData);
  36. } else {
  37. foreach ($scopeData as &$sData) {
  38. $sData = $this->configPlaceholder->process($sData);
  39. }
  40. }
  41. }
  42. return $data;
  43. }
  44. }